Introduction: While working on asp.net application we
may need to create a user input form where user fills a form having different
type of input boxes. In this case we have to restrict user to enter only valid
data in the form. We can handle this
throughFilteredTextBoxExtender control of AJAX.
Steps are as follows:
-->Download and install ajax toolkit to Visual Studio from http://ajaxcontroltoolkit.codeplex.com/
-->add reference to ajaxcontroltoolkit.dll
-->place a script manager on the design page
-->add FilteredTextBoxExtender by clicking on the textbox and then as follows:
1) Allowing only "Numbers"
<asp:TextBox ID="txtMob" runat="server"></asp:TextBox>
<asp:FilteredTextBoxExtender ID="txtMob_FilteredTextBoxExtender" runat="server"
Enabled="True" TargetControlID="txtMob" FilterType="Custom" FilterMode="ValidChars" ValidChars="0123456789">
</asp:FilteredTextBoxExtender>
2) Allowing only "numbers and hiphen sign"
<asp:TextBox ID="txtPhone" runat="server"></asp:TextBox>
<asp:FilteredTextBoxExtender ID="txtPhone_FilteredTextBoxExtender"
runat="server" Enabled="True" TargetControlID="txtPhone" FilterType="Custom" FilterMode="ValidChars" ValidChars="0123456789-">
</asp:FilteredTextBoxExtender>
3) Allowing only "Characters and space"
<asp:TextBox ID="txtName" runat="server" ></asp:TextBox>
<asp:FilteredTextBoxExtender ID="txtName_FilteredTextBoxExtender"
runat="server" Enabled="True" TargetControlID="txtName" FilterType="Custom,LowercaseLetters,UppercaseLetters" FilterMode="ValidChars" ValidChars=" ">
</asp:FilteredTextBoxExtender>
Steps are as follows:
-->Download and install ajax toolkit to Visual Studio from http://ajaxcontroltoolkit.codeplex.com/
-->add reference to ajaxcontroltoolkit.dll
-->place a script manager on the design page
-->add FilteredTextBoxExtender by clicking on the textbox and then as follows:
1) Allowing only "Numbers"
<asp:TextBox ID="txtMob" runat="server"></asp:TextBox>
<asp:FilteredTextBoxExtender ID="txtMob_FilteredTextBoxExtender" runat="server"
Enabled="True" TargetControlID="txtMob" FilterType="Custom" FilterMode="ValidChars" ValidChars="0123456789">
</asp:FilteredTextBoxExtender>
2) Allowing only "numbers and hiphen sign"
<asp:TextBox ID="txtPhone" runat="server"></asp:TextBox>
<asp:FilteredTextBoxExtender ID="txtPhone_FilteredTextBoxExtender"
runat="server" Enabled="True" TargetControlID="txtPhone" FilterType="Custom" FilterMode="ValidChars" ValidChars="0123456789-">
</asp:FilteredTextBoxExtender>
3) Allowing only "Characters and space"
<asp:TextBox ID="txtName" runat="server" ></asp:TextBox>
<asp:FilteredTextBoxExtender ID="txtName_FilteredTextBoxExtender"
runat="server" Enabled="True" TargetControlID="txtName" FilterType="Custom,LowercaseLetters,UppercaseLetters" FilterMode="ValidChars" ValidChars=" ">
</asp:FilteredTextBoxExtender>
0 comments:
Post a Comment