在 nextbuttonclick 事件之后,如何在向导的上一步中禁用所有 checbkoxes 或所有单选按钮?
问问题
434 次
2 回答
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;
}
}
于 2013-01-10T13:38:29.933 回答
0
好的,我已经检查过了,它不起作用,当step.allowreturn=false
.
于 2013-01-11T11:47:51.863 回答