Monday, 29 December 2014

Restrict <,>,~,^,\,? characters in ASP.NET Controls


This is very helpful post for all developers belongs to AJAX with any other technologies like ASP>NET,JAVA,....


In some scenarios, user don't want to allow some special characters in TextBox or input controls then we use AJAX FilteredTextBoxExtender control.


Restricted Special characters are <,>,~,^,\,?

Ex : We used Asp.Net Textbox control and add my control id to FilteredTextBoxExtender for reference

 <asp:TextBox ID="txtboxOwnerContent" runat="server" Height="18px" Width="302.5px"
                        MaxLength="150" CssClass="bordercolor defaultfontname" />
                    <cc1:FilteredTextBoxExtender ID="FilteredTextBoxExtender8" runat="server" FilterType="Custom"
                        FilterMode="InvalidChars" InvalidChars="<,>,~,^,\,?" TargetControlID="txtboxOwnerContent" />


With the above example,user can't able to type those characters.


That's it,

Happy Coding :)

No comments:

Post a Comment