Reputation: 193
how can I disable all checbkoxes or all radiobuttons in previous step of wizard after nextbuttonclick event?
Upvotes: 0
Views: 452
Reputation: 193
Ok, I've checked and it doesn't work, when step.allowreturn=false
.
Upvotes: 0
Reputation: 17039
ASPX:
<asp:Wizard ID="Wizard1" runat="server"
onnextbuttonclick="Wizard1_NextButtonClick">
<WizardSteps>
<asp:WizardStep ID="Step1" runat="server" Title="Step 1">
<asp:RadioButton ID="RadioButton1" Text="Option 1" runat="server" />
<asp:RadioButton ID="RadioButton2" Text="Option 2" runat="server" />
<asp:RadioButton ID="RadioButton3" Text="Option 3" runat="server" />
</asp:WizardStep>
<asp:WizardStep ID="Step2" runat="server" Title="Step 2">
</asp:WizardStep>
</WizardSteps>
</asp:Wizard>
Code behind:
protected void Wizard1_NextButtonClick(object sender, WizardNavigationEventArgs e)
{
if (Wizard1.ActiveStep == Step1)
{
IEnumerable<RadioButton> controls = FindControls<RadioButton>(Step1);
controls.ToList().ForEach(c => c.Enabled = false);
}
}
IEnumerable<T> FindControls<T>(Control parent) where T : Control
{
foreach (Control c in parent.Controls)
{
if (c.GetType() == typeof(T)) yield return (T)c;
foreach (var subControl in FindControls<T>(c))
yield return subControl;
}
}
Upvotes: 2