Solved

asp.net validationgroup

Posted on 2009-05-03
4
397 Views
Last Modified: 2012-05-06
Hi, expert pls help, let say i have control as follow

2 Textbox
2 RequiredFieldValidator bind each of textbox above.
2 button

1button and 1 textbox above i added as validationgroup="group1"
so that button will fire a validation check b4 submit

the other one button i would like it to validate textbox1 and textbox2 above together, is there any way to do it.
0
Comment
Question by:john8098
  • 2
  • 2
4 Comments
 
LVL 9

Expert Comment

by:tillgeffken
ID: 24290314
I'm assuming those two buttons are not your submit buttons for your form but only there to trigger the validation?
0
 

Author Comment

by:john8098
ID: 24291704
the two asp.net server control button will perform send the mail. before it send the mail, i need 1 perform partial validate and one is fill validate.
0
 
LVL 9

Accepted Solution

by:
tillgeffken earned 125 total points
ID: 24292886
Try the following:

<TextBox1 ValidationGroup="ValOne" />
<RequiredFieldValidator ID="TextBox1RequiredFieldValidator" ValidationGroup="ValOne" />
<TextBox2 ValidationGroup="ValTwo" />
<RequiredFieldValidator ID="TextBox2RequiredFieldValidator" ValidationGroup="ValTwo" />
 
<Button1 ValidationGroup="ValOne" />
<Button2 ValidationGroup="ValTwo" OnClick="Button2_Click" />

In codebehind:

protected void Button2_Click(object sender, EventArgs e)
{
  if (Page.IsValid)
    {
      TextBox1RequiredFieldValidator.Validate();
      if (TextBox1RequiredFieldValidator.IsValid)
      {
          //Do your thing
      }
   }
}
0
 

Author Closing Comment

by:john8098
ID: 31577331
Well done.pal!
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

707 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

14 Experts available now in Live!

Get 1:1 Help Now