How to allow only numbers, characters in the textbox using FilteredTextBoxExtender control of Ajax,

Introduction: In previous articles i explained How to install Ajax Control Toolkit in Visual Studio and Ajax AutoCompleteExtender control example in asp.net using C#,VB.Net without using web service and Ajax AutoCompleteExtender control example in asp.net C#,VB.Net using web service and CalendarExtendar control of Ajax in asp.net.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 through FilteredTextBoxExtender 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>
Previous
Next Post »

If you have any question about any post, Feel free to ask.You can simply drop a comment below post or contact via Contact Us form. Your feedback and suggestions will be highly appreciated. Also try to leave comments from your account not from the anonymous account so that i can respond to you easily..