FilteredTextBox控件,该控件用于控制用户的输入值的范围。
实例代码如下所示:
实例代码如下所示:
<%
@PageLanguage
=
"
C#
"
AutoEventWireup
=
"
true
"
CodeFile
=
"
FilteredTextBoxDemo.aspx.cs
"
Inherits = " FilteredTextBoxDemo " %>
<% @RegisterAssembly = " System.Web.Extensions,Version=1.0.61025.0,Culture=neutral,
PublicKeyToken=31bf3856ad364e35 "
Namespace = " System.Web.UI " TagPrefix = " asp " %>
<% @RegisterAssembly = " AjaxControlToolkit " Namespace = " AjaxControlToolkit " TagPrefix = " cc1 " %>
<! DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//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 >
Inherits = " FilteredTextBoxDemo " %>
<% @RegisterAssembly = " System.Web.Extensions,Version=1.0.61025.0,Culture=neutral,
PublicKeyToken=31bf3856ad364e35 "
Namespace = " System.Web.UI " TagPrefix = " asp " %>
<% @RegisterAssembly = " AjaxControlToolkit " Namespace = " AjaxControlToolkit " TagPrefix = " cc1 " %>
<! DOCTYPEhtmlPUBLIC"-//W3C//DTDXHTML1.0Transitional//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 >