Solved

asp.net vb.net validate textbox in a gridview template field

Posted on 2009-05-07
3
1,231 Views
Last Modified: 2012-08-14
How can validate a textbox to only accept numbers.
0
Comment
Question by:rflorencio
  • 2
3 Comments
 
LVL 41

Accepted Solution

by:
guru_sami earned 500 total points
Comment Utility
check this:
The RequiredFieldValidator  is for empty text and
RegularExpressionValidator  is to check for numeric...
If your textbox can accept empty values remove RequireFieldValidator..
Make sure to set ValidationGroupProperty...

Check this for more info: http://quickstarts.asp.net/QuickStartv20/aspnet/doc/validation/default.aspx

<asp:TextBox ID="Txthr" runat="server" ValidationGroup="Txthr1"></asp:TextBox>
      <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
          ControlToValidate="Txthr" ErrorMessage="RequiredFieldValidator"
          ValidationGroup="Txthr1">*</asp:RequiredFieldValidator>
      <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server"
          ControlToValidate="Txthr" ErrorMessage="RegularExpressionValidator"
          ValidationExpression="^[0-9]*" ValidationGroup="Txthr1">*</asp:RegularExpressionValidator>
      <asp:Button ID="Button2" runat="server" Text="Button" ValidationGroup="Txthr1" />
0
 

Author Comment

by:rflorencio
Comment Utility
Regularexpressionvalidator works well, but RequiredFieldValidator no. Appears the error message in all lines of gridview
0
 

Author Comment

by:rflorencio
Comment Utility
Sorry, This fine.
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
This video discusses moving either the default database or any database to a new volume.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now