Answer: We will use Regular Expression Validator control to validate Textbox.Below codd will allow only characters with no spaces.
<asp:TextBox runat="server" Id="txt_first_name" />
<asp:RegularExpressionValidator runat="server" id="rex_first_name" ControlToValidate="txt_first_name" ValidationExpression="^[a-zA-Z]$" ErrorMessage="Only Characters Allowed" />
Asked In: Many Interviews |
Alert Moderator