I have a master page that contains a search box which is validated as a required field before the user can submit the search field.
The problem I’m having now is that one of my content pages has a DetailsView which won’t let me edit a record, because the search box coming from the master page is blank.
The structure of the code is like this:
Master Page:
<form runat="server">
<asp:RequiredFieldValidator ID="SearchBoxRequiredFieldValidator"
runat="server" ControlToValidate="searchTextBox"
Display="None" ErrorMessage="Enter an employee's last name"></asp:RequiredFieldValidator>
<asp:TextBox ID="searchTextBox" autocomplete ="off" runat="server" Width="180px"></asp:TextBox>
<asp:Button ID="SearchButton" runat="server" Text="Employee Search"/>
<!--.....-->
<asp:ContentPlaceHolder ID="MainContent" runat="server"/>
</form>
The “MainContent” placeholder is populated with a page with only a DetailsView. How should I change my code so that I can submit forms from my MainContent pages, but also allow the Master page’s search feature to function properly?
I’m pretty new to asp.net forms, so any help is greatly appreciated!
Take a look at ValidationGroups. You can separate each logical form into different validation groups giving the effect of multiple discrete forms.