I want to make either last name or first name required. Below is the code and it does not work as expected.
Once a RequiredFieldValidator is enabled by the Page_Load() method, there is no way to make it execute that method again to disable the RequiredFieldValidator. How can that be fixed?
Let's say after the first time the page loads, I click the Find button without entering any name.
That causes RequiredFieldValidator1 to be enabled by the Page_Load() method.
Now I enter first name and click Find; it does not execute Page_Load() and thus requires last name.
It should not require last name. How do you set RequiredFieldValidator's Enabled attribute when the server code is not executed?
Last Name: <asp:TextBox ID="LastName" runat="server"></asp:TextBox>
First Name: <asp:TextBox ID="FirstName" runat="server"></asp:TextBox>
<asp:Button ID="Button1" Text="Find" runat="server" OnClick="Button_Click" />
View Complete Post