FilteredTextBox控件,該控件用於控制用戶的輸入值的范圍。
實例代碼如下所示:
<%...@ Page Language="C#" AutoEventWireup="true" CodeFile="FilteredTextBoxDemo.ASPx.cs"
Inherits="FilteredTextBoxDemo" %>
<%...@ Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35"
Namespace="System.Web.UI" TagPrefix="ASP" %>
<%...@ Register Assembly="AjaxControlToolkit" Namespace="AJaxControlToolkit" TagPrefix="cc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHtml 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xHtml1-transitional.dtd">
<html XMLns="http://www.w3.org/1999/xHtml" >
<head runat="server">
<title>無標題頁</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<ASP:ScriptManager ID="ScriptManager1" runat="server">
</ASP:ScriptManager>
<table border="0">
<tr>
<td>只允許輸入數字</td>
<td><ASP:TextBox ID="TextBox1" runat="server" /> </td>
</tr>
<tr>
<td>只允許輸入小寫字母:</td>
<td><ASP:TextBox ID="TextBox2" runat="server" /></td>
</tr>
<tr>
<td>只允許輸入 (+,-,*,/,=,.) 和數字:</td>
<td> <asp:TextBox ID="TextBox3" runat="server"></ASP:TextBox></td>
</tr>
</table>
<cc1:FilteredTextBoxExtender
ID="FilteredTextBoxExtender1"
runat="server"
TargetControlID="TextBox1"
FilterType="Numbers" />
<cc1:FilteredTextBoxExtender
ID="FilteredTextBoxExtender2"
runat="server"
TargetControlID="TextBox2"
FilterType="LowercaseLetters" />
<cc1:FilteredTextBoxExtender
ID="FilteredTextBoxExtender3"
runat="server"
TargetControlID="TextBox3"
FilterType="Custom, Numbers"
ValidChars="+-=/*()." />
</div>
</form>
</body>
</Html>