Multiple submit button with validations in asp.net
In ASP.NET when we have multiple input section with required field validator (Like on header for login with userid & Password is required and second on footer for subscription) when we click on subscription login section's userid required field validator activates and say userid required & i can not submit subscription.
when i submit subscription details login section should not have concern with this. how to avoid th开发者_如何学Pythonis conflicts.
You have to use the ValidationGroup property for the controls, the validators and the control that submits the postback.
For each logic group you set the same value of the ValidationGroup property
@Citronas answer is correct, but to add to it, you should also ensure you handle the default behavior correctly when using multiple input forms. Put a panel around each and use DefaultButton
to identify the submit control for that panel. This will ensure that if the user presses enter (which is very typical, especially for login forms) the correct submit handler is used.
Also note that this won't work reliably for all submit control types. See Link Button on the page and set it as default button, work fine in IE but not in Mozila
A solution is suggested there for this problem, though personally I prefer to address this just by including a hidden button control that uses the same event handler as your visible control, e.g.
<asp:Button runat="server" onclick="Search_Click" ID="SearchButton_Default" style="display:none;" />
Then make this hidden button the default control instead of your LinkButton
精彩评论