Hello everybody !
I work on asp.net webform app and I would to disable an asp:RequierFieldValidator on radio button list.
My radio button list :
<asp:RadioButtonList runat="server" ID="rbtnO360Sync" RepeatDirection="Horizontal" AutoPostBack="true" OnSelectedIndexChanged="RbtnO360Sync_SelectedIndexChanged"
EnableTheming="True" EnableViewState="true">
<asp:ListItem Selected="True" Text="Oui" Value="True" />
<asp:ListItem Text="Non" Value="False" />
</asp:RadioButtonList>
The event RbtnO360Sync_SelectedIndexChanged :
private void UpdateO365SyncSelected()
{
if (SyncO365 && AD)
{
rfvIdentifiantMDM.Enabled = true;
rfvIdentifiantMDM.Visible = true;
rfvIdentifiantMDM.ControlToValidate = txtIdentifiantMDM.ID;
rfvIdentifiantMDM.ValidationGroup = "Form";
}
else
{
rfvIdentifiantMDM.Visible = false;
rfvIdentifiantMDM.Enabled = false;
rfvIdentifiantMDM.ValidationGroup = null;
rfvIdentifiantMDM.ControlToValidate = null;
}
protected void RbtnO360Sync_SelectedIndexChanged(object sender, EventArgs e)
{
UpdateO365SyncSelected();
}
My Required Field Validator and the associated field:
<asp:TextBox runat="server" ID="txtIdentifiantMDM" Visible="true" ReadOnly="true"></asp:TextBox>
<asp:RequiredFieldValidator ID="rfvIdentifiantMDM" ViewStateMode="Disabled" runat="server" Display="dynamic" Text="* Obligatoire pour les comptes Office 365" SetFocusOnError="true" />
By default the required field validator is activated.
when I click on radio button item "Non" the requied field validator is allways activate
My Question How to desactivate it on click to "Non" radio button item ?
Thanks for you reply !
What I have tried:
I tried to
rfvIdentifiantMDM.Visible = false;
rfvIdentifiantMDM.Enabled = false;
rfvIdentifiantMDM.ValidationGroup = null;
rfvIdentifiantMDM.ControlToValidate = null;
but nothing works