Expiring Today—Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

asp.net validationgroup

Posted on 2009-05-03
4
Medium Priority
?
446 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
[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
  • 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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

719 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