Solved

asp.net validationgroup

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
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…
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…

751 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