I have a user control, where I have two panels: one on the left and the other on the left, some kind of billing information, and the right - delivery information, each field in the delivery information requires the identifier, these panels are wrapped to the update panel. The default state is that both panels are visible, under the panels the "Delivery is the same as billing" checkbox is selected when you check that the panel on the right, the "Send Panel" disappears, and then you continue.
Problem . Suppose I delete the text in the delivery name, and I do not find anywhere else. Then I go to the checkbox "Same as billing", for a while it shows a check in red and then it disappears. I tried to create a function that disables the ie validator
RequireFieldValidator1.Enabled = false;
It works great in terms when it doesn't show validation before the transfer panel disappears, but I will say that I changed my mind and clicked it again to display it. Now, when I erase the name in the send panel and click elsewhere, it does not allow me to go anywhere, but it does not show the verification text.
So, I made this logic:
if (ckSameBilling.checked)
{
RequiredFieldValidator.Enabled = false;
}
else
{
RequiredFieldValidator.Enabled = true;
}
But now he has returned to the same behavior as I, above, to clear the delivery name and click on the checbox. I can see the red check for a moment.
Associated Code
//All this is wrapped in an update panel
<asp:Panel ID="pnl" runat="server"><div>
asp:TextBox ID="txtShippingFirstName" runat="server" Width="130px" Columns="30"
MaxLength="100" asp:TextBox><div>
<asp:RequiredFieldValidator ID="Requiredfieldvalidator1" ErrorMessage="Name Required"
ControlToValidate="txt"
runat="server" Display="Dynamic" CssClass="Error">
</asp:RequiredFieldValidator>
</asp:Panel>
<div style="margin-left: 145px;">
<asp:CheckBox ID="Billing" runat="server" Font-Bold="True"
Text"Same as Billing" OnCheckedChanged="Billing_CheckedChanged"
AutoPostBack="True" />
</div>
Codebehind:
protected void Billing_CheckedChanged(object sender, EventArgs e)
{
if (Billing.Checked)
{
DisableEnable(true);
pnl.Visible = false;
}
else
{
DisableEnable(false);
pnl.Visible = true;
}
}
private void DisableEnable(bool enable)
{
if (enableFields)
{
Requiredfieldvalidator1.Enabled = false;
}
else
{
Requiredfieldvalidator1.Enabled = true;
}
}