.NET Two "forms" On A Page And Their Validators
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?
Your problem can be solved with asp.net ValidationGroups.
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.
- → How to Fire Resize event after all images resize
- → URL routing requires /Home/Page?page=1 instead of /Home/Page/1
- → Getting right encoding from HTTPContext
- → How to create a site map using DNN and C#
- → I want integrate shopify into my mvc 4 c# application
- → Bootstrap Nav Collapse via Data Attributes Not Working
- → Shopify api updating variants returned error
- → ASP.NET C# SEO for each product on detail page on my ECOMMERCE site
- → SEO Meta Tags From Behind Code - C#
- → How to implement search with two terms for a collection?