RSS

Textbox to allow integer only

21 Sep

You should look at using a RegularExpressionValidator. Validator may ASPX page, which you control with the strengthening of property ControlToValidate

Code;

  <asp:RegularExpressionValidator id="RegularExpressionValidator1" 
                     ControlToValidate="TextBox1"
                     ValidationExpression="^\d+$"
                     Display="Static"
                     ErrorMessage="value must be an integer"
                     runat="server"/>


n your button you would set the CausesValidation property to true.



<asp:Button ID="SomeButton"
                    Text="Submit"
                    CausesValidation="True"
                    runat="server"/>
Advertisements
 
Leave a comment

Posted by on September 21, 2010 in ASP.Net Validation

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: