can somebody guide me on this…
I have a panel (say, panel1) inside another panel (say, outer-panel)….The panel1 is visible only when a checkbox is checked in the outer-panel.
I have many text boxes in the panel1. I have to put a validation on all the boxes.
I have to enable the validations on certain conditions,say, if textbox 1 is filled only then the required-field validator for textbox 2 should be enabled and vice-versa.
I did write code in the page_load for this.
Expand|Select|Wrap|Line Numbers
- if (txt1.Text != "")
- {
- required_txt2.Enabled = true;
- }
- else
- {
- required_txt2.Enabled = false;
- }
- if (txt2.Text != "")
- {
- required_txt1.Enabled = true;
- }
- else
- {
- required_txt1.Enabled = false;
- }
the asp code for the validators is,
Expand|Select|Wrap|Line Numbers
- <asp:RequiredFieldValidator ID="required_txt1" runat="server" ErrorMessage="Please enter the text."
- ControlToValidate="txt1" EnableClientScript="false" Enabled="false" Display="Dynamic"
- SetFocusOnError="true" ValidationGroup="Submit">*</asp:RequiredFieldValidator>
- <asp:RequiredFieldValidator ID="required_txt2" runat="server" Enabled="false" EnableClientScript="false"
- ErrorMessage="Please enter the text 2." ControlToValidate="txt2" SetFocusOnError="true"
- Display="Dynamic" ValidationGroup="Submit">*</asp:RequiredFieldValidator>