Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

asp.net validationgroup

Posted on 2009-05-03
4
Medium Priority
?
451 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 375 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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…
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…
Suggested Courses

877 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