AJAX Control Toolkit ——FilteredTextBoxExtender(文本过滤)

FilterTextBoxExtender

 TargetControlID - 要执行文本过滤的TextBox ID

  FilterType - 过滤类型,Numbers,LowercaseLetters(小写),UpcaseLettes(大写)and Custom(default)

  FilterMode-ValidChars(default) and InvalidChars(低版本中不存在次属性),设置其中任意一个值时,FilterType必须为Custom,也就是说FilterType是同时可以设置两种类型(Custom和其中任意一中),具体可以参看例子

 ValidChars-有效字符,FilterMode中必须有Custom

 InvalidChars-无效字符,FliterMode中必须有Custom

 FilterInterval-the default is 250ms

More Information of FilterTextBoxExtender

Demo>>>

 1 <asp:ScriptManager ID="ScriptManager1" runat="server" />
2 <div>
3 <ajaxToolkit:FilteredTextBoxExtender ID="FilteredTextBoxExtender1" runat="server"
4 TargetControlID="TextBox1" FilterType="Numbers" ClientIDMode="Inherit">
5 </ajaxToolkit:FilteredTextBoxExtender>
6 <ajaxToolkit:FilteredTextBoxExtender ID="FilteredTextBoxExtender2" runat="server"
7 TargetControlID="TextBox2" FilterType="LowercaseLetters">
8 </ajaxToolkit:FilteredTextBoxExtender>
9 <ajaxToolkit:FilteredTextBoxExtender ID="FilteredTextBoxExtender3" runat="server"
10 TargetControlID="TextBox3" FilterType="Custom, Numbers" ValidChars="+-=/*().">
11 </ajaxToolkit:FilteredTextBoxExtender>
12 <table border="0">
13 <tr>
14 <td>
15 Only digits are allowed here:
16 </td>
17 <td>
18 <asp:TextBox ID="TextBox1" runat="server">
19 </asp:TextBox>
20 </td>
21 </tr>
22 <tr>
23 <td>
24 Only lower-case letters are allowed here:
25 </td>
26 <td>
27 <asp:TextBox ID="TextBox2" runat="server">
28 </asp:TextBox>
29 </td>
30 </tr>
31 <tr>
32 <td>
33 Only math symbols (+,-,*,/,=,.) and numbers:
34 </td>
35 <td>
36 <asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
37 </td>
38 </tr>
39 </table>


额外还想补充点,该控件与验证控件不同的是,如果不符合的内容是无法输入的。

  

  

 

原文地址:https://www.cnblogs.com/January/p/2126077.html