English 中文(简体)
有条件地将控制添加到协会。 不论情况如何,网络作为控制收集的一部分所展示的令人信服的步骤
原标题:Controls added conditionally to a ASP.NET wizard step displayed as part of controls collection irrespective of the condition

我有一个伙伴关系。 该网络采取重大步骤,包括根据前一个步骤所选定的内容进行用户控制:

        <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>

这种做法似乎奏效,避免了在网页上积极增加控制的问题,以及随之而来的背后头痛之间的一切持续存在。

然而,我还有以下法典用来验证该步骤中选择的内容:

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_ReportAStep3_ReportB-,而不仅仅是由于<代码>/code>而列入的控制<>。 当然,当该网页上台时,只有一种控制是输出的。

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?

提前感谢!

问题回答

部分 旗帜似乎是一种 b子,你正在对地块进行比较。 此外,我看不出对这一“一些Flag”变量的任何声明,它是否ool? 或者这是否是一种扼杀?





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!