在nextbuttonclick事件之后如何在向导的上一步中禁用所有checbkoxes或所有radiobuttons?
答案 0 :(得分:2)
<强> 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>
代码背后:
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;
}
}
答案 1 :(得分:0)
好的,我已经检查过,当step.allowreturn=false
时,它无效。