user927777
user927777

Reputation: 71

validating a user controls form without validating the form on the page

I have a page with two user controls(modal popups in each), each with its own form. When a user interacts with the form on either user control, I would like the user controls form to validate without causing the page to validate as well. Currently it is causing both forms and the page to validate, which is a huge problem. How can I cause each item(user controls form and page form) to validate separately?

Upvotes: 0

Views: 482

Answers (1)

Murtaza
Murtaza

Reputation: 3065

I would like to explain you the validation, here

Assuming Following is your scenario:

your page - with submit button - causes validation user control1 - with button - causes validation user control2 - with button - causes validation

when u hit any of the one button, all your validations error message pops up. (hope i am right!)

if you are using Required field validator, you can set validation Groups and to each user control will have a different groupname, this u will add to your button in aspx form. eg.

Note Validation Group below

<asp:RequiredFieldValidator ID="EmailRequired" runat="server" 
ControlToValidate="UserName" CssClass="errormsg" ErrorMessage="E-mail is required." 
ValidationGroup="RegisterUser" Display="Dynamic" ToolTip="E-mail is required.">
</asp:RequiredFieldValidator>

Submit button which causes validation

<asp:Button ID="CreateUser" CssClass="sendBtn" runat="server" CommandName="MoveNext" 
Text="Sign up" ValidationGroup="RegisterUser" />

The above button will only validate the fields marked with same Validation group.

Upvotes: 1

Related Questions