Solved

asp.net validationgroup

Posted on 2009-05-03
4
411 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

920 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