HTML SOURCE OF PAGE
If we want to create textbox which restrict certain type of characters or special characters, we can do as follows.
We can change FilteredTextboxExtender properties in code behind if we need to allow or change textbox type on runtime as follows.
1: <asp:ToolkitScriptManager ID="ToolkitScriptManager1"
2: runat="server">
3: </asp:ToolkitScriptManager>
4:
5: <asp:TextBox ID="txtUpperCase" runat="server"/>
6: <asp:FilteredTextBoxExtender ID="UpperCase"
7: runat="server"
8: TargetControlID="txtUpperCase"
9: FilterType="UppercaseLetters">
10: </asp:FilteredTextBoxExtender>
11:
12: <asp:TextBox ID="txtLowerCase" runat="server"/>
13: <asp:FilteredTextBoxExtender ID="LowerCase"
14: runat="server"
15: TargetControlID="txtLowerCase"
16: FilterType="LowercaseLetters">
17: </asp:FilteredTextBoxExtender>
18:
19: <asp:TextBox ID="txtNumbers" runat="server"/>
20: <asp:FilteredTextBoxExtender ID="Numbers"
21: runat="server"
22: TargetControlID="txtNumbers"
23: FilterType="Numbers">
24: </asp:FilteredTextBoxExtender>
25:
26: <asp:TextBox ID="txtCustom" runat="server"/>
27: <asp:FilteredTextBoxExtender ID="Custom"
28: runat="server"
29: TargetControlID="txtCustom"
30: FilterType="Custom"
31: ValidChars="123abc$%">
32: </asp:FilteredTextBoxExtender>
If we want to create textbox which restrict certain type of characters or special characters, we can do as follows.
1: <asp:TextBox ID="TextBox1" runat="server"/>
2: <asp:FilteredTextBoxExtender ID="Custom"
3: runat="server"
4: TargetControlID="TextBox1"
5: FilterMode="InvalidChars"
6: InvalidChars="!@#$%^&*()~?><|\';:">
7: </asp:FilteredTextBoxExtender>
We can change FilteredTextboxExtender properties in code behind if we need to allow or change textbox type on runtime as follows.
1
using
AjaxControlToolkit;
2
txtUpperCase_FilteredTextBoxExtender.FilterType = FilterTypes.Custom;
3
txtUpperCase_FilteredTextBoxExtender.FilterMode = FilterModes.ValidChars;
4
txtUpperCase_FilteredTextBoxExtender.ValidChars =
"1234567890"
;
0 comments:
Post a Comment