Solved

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

Posted on 2009-05-07
3
1,241 Views
Last Modified: 2012-08-14
How can validate a textbox to only accept numbers.
0
Comment
Question by:rflorencio
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 41

Accepted Solution

by:
guru_sami earned 500 total points
ID: 24326872
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
ID: 24327547
Regularexpressionvalidator works well, but RequiredFieldValidator no. Appears the error message in all lines of gridview
0
 

Author Comment

by:rflorencio
ID: 24327841
Sorry, This fine.
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
ASP.NET Calendar Control 5 48
Adjust the codes 3 60
CSS question 16 59
Ajax calendar distorted 4 14
ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

738 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