Question:
Hello,
I’m using a asp.net required field validators for various fields in the form and I’m using a master page . I have a search bar above form. I’m unable to use the search form due to the require field validators.
When ever I type search I’m asked for the required fields. How do I make sure that fields are checked only when the form containing the field is being posted
Solution:
Add validationGroup property for the Required Field Validator and the Controls like
<asp:Button id=”SearchButton” Text=”Search” Runat=”Server” />
<asp:TextBox id=”TextBox1″ Runat=”Server” />
<asp:TextBox id=”TextBox2″ Runat=”Server” />
<asp:RequiredFieldValidator ControlToValidate=”TextBox1″ runat=”Server” Text=”*” ValidationGroup=”SaveGrp” />
<asp:RequiredFieldValidator ControlToValidate=”TextBox2″ runat=”Server” Text=”*” ValidationGroup=”SaveGrp” />
<asp:Button id=”SaveButton” Text=”Save” Runat=”Server” ValidationGroup=”SaveGrp” />