我有一个伙伴关系。 该网络采取重大步骤,包括根据前一个步骤所选定的内容进行用户控制:
<asp:WizardStep ID ="WizardStep3" runat="server" Title="Step 3">
<%switch (someFlag)
{
case ("value a"):
%>
<wizStep:Step3_ReportA ID="Step3_ReportA" runat="server" />
break;
case ("value b"):
%>
<wizStep:Step3_ReportB ID="Step3_ReportB" runat="server" />
<%
break;
} %>
</asp:WizardStep>
这种做法似乎奏效,避免了在网页上积极增加控制的问题,以及随之而来的背后头痛之间的一切持续存在。 然而,我还有以下法典用来验证该步骤中选择的内容: 我发现的混淆是: So why do all controls in the switch statement get reported as belonging to the wizard step controls collection and how do I find which is the one that the switch statement has actually selected? 提前感谢!protected void wizReportWizard_NextButtonClick(object sender, WizardNavigationEventArgs e)
{
int stepId = e.CurrentStepIndex;
var wizardStepControls = wizReportWizard.WizardSteps[stepId].Controls.OfType<BaseWizardStep>().ToList();
foreach (var wizardStepControl in wizardStepControls)
{
if (wizardStepControl.IsStepValid())
{
wizardStepControl.DoSomething();
}
else
{
e.Cancel = true;
return;
}
}
}
wizardStepControls
载有两项步骤控制(Step3_ReportA
和Step3_ReportB
-,而不仅仅是由于<代码>