views:

83

answers:

2

Hi,

I have got a page that has 2 "forms" (What I mean by a form here is a Panel consisting of: textboxes, validators and a button).

(I got 2 here because one of them is actually on the MasterPage, shown all the time)

The problem is when you try to submit to one of the form, it will validate the other form, which of course is blank and invalid.

How do you solve this problem?

Thank you.

+5  A: 

Your problem can be solved with asp.net ValidationGroups.

http://weblogs.asp.net/scottgu/archive/2004/10/24/246945.aspx

Basically, you group the controls to be validated using a uniquely named validation group. Like so:

<asp:Textbox ID="txt" runat="server" />
<asp:RequiredFieldValidator id="rfv" runat="server" ControlToValidate="txt" ValidationGroup="masterGroup">* Required!</asp:RequiredFieldValidator>
<br />
<asp:Button id="btnSubmitMaster" runat="server" Text="Submit!" ValidationGroup="masterGroup" />

If you group your inputs like this, then assign the validation group to the control that submits the form, the inputs in the other validation groups won't be validated.

Jorge Alves
A: 

ValidationGroup! That's it! Thank you!