在ASP.NET code-背后推进向导 [英] Advancing wizard from code-behind in ASP.NET

查看:107
本文介绍了在ASP.NET code-背后推进向导的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我的页面上的向导,它有一个下一步按钮。我想点击页面上的其他按钮时,从code-背后的点击该按钮。

I have a wizard on my page, and it has a "Next" button. I would like to "click" that button from code-behind when clicking another button on the page.

更具体地说:
还有就是我的页面上的按钮有两个功能:单击它,在回发后,它要么设置重新加载页面,并显示一个弹出所需的code,或者它的进步,如果它认为弹出不必要的向导。如果显示的弹出窗口,它包含一个按钮来推进向导。

More specifically: There is a button on my page that has two functions: after clicking it, in the postback, it either sets up the code required to reload the page and display a popup, or it advances the wizard if it deems the popup unnecessary. In case the popup is shown, it contains a button to advance the wizard.

有些code片段:

向导初始化:

<asp:Wizard ID="RegistrationWizard" meta:resourcekey="RegistrationWizard"
    runat="server" OnFinishButtonClick="RegistrationWizard_FinishButtonClick" 
    OnActiveStepChanged="RegistrationWizard_ActiveStepChanged" 
    OnNextButtonClick="RegistrationWizard_NextButtonClick">

按钮,显示弹出式或前进:

Button to show popup or advance:

<asp:Button ID="btnModulesNextPostBack" runat="server" CssClass="submit rounded"
    meta:resourcekey="btnNext" onclick="btnModulesNextPostBack_Click" />

按钮进入向导:

<asp:Button ID="btnModulesStepNext" runat="server" CssClass="submit rounded" 
    meta:resourcekey="btnNext" CommandName="MoveNext" />

$ C $的btnModulesNextPostBack_Click方法的C-背后:

Code-behind of the btnModulesNextPostBack_Click method:

protected void btnModulesNextPostBack_Click(object sender, EventArgs e)
{
    showPopup = false; // if set to true: will open popup in postback
    // ... code to determine if popup should be shown
    if (!showNewsletterPopup)
    {
        // TODO! trigger "move to next step in wizard"
    }
}

我不知道是什么在TODO行的地方,因为我要确保有关向导中的所有其他方法被调用以相同的顺序照常太(RegistrationWizard_NextButtonClick和RegistrationWizard_ActiveStepChanged,也许别人向导code内部调用)。

I don't know what to place in the TODO line, because I want to be sure that all other methods related to the wizard get called in the same order as usual too (RegistrationWizard_NextButtonClick and RegistrationWizard_ActiveStepChanged and maybe others the wizard code calls internally).

我怎样才能做到这一点? (.NET版本是4.0)

How can I do this? (.net version is 4.0)

推荐答案

您应该能够只是递增 ActiveStepIndex

Wizard1.ActiveStepIndex++;

您也可以使用通过MoveTo 方法:

Wizard1.MoveTo(WizardStep1);

最后,如果你想向前和向后导航向导,您可以使用 NextButtonClick previousButtonClick

protected void wzServiceOrder_PreviousButtonClicked(object sender, WizardNavigationEventArgs e)
{
    //decrement the active step index
    wzServiceOrder.ActiveStepIndex--;

    //move the wizard to the active step
    wzServiceOrder.MoveTo(wzServiceOrder.ActiveStep);                        
}

/// <summary>
/// Handles wzServiceOrder OnNextButtonClick event.
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void wzServiceOrder_NextButtonClicked(object sender, WizardNavigationEventArgs e)
{
    //increment the active step index
    Wizard1.ActiveStepIndex++;

    //move the wizard to the active step
    Wizard1.MoveTo(Wizard1.ActiveStep);

    if (e.NextStepIndex > Wizard1.WizardSteps.IndexOf(WizardStep1))
    {
        if (!contactsExist)
        {
            Popop1.Show();
            e.Cancel = true;
        }
    }
}

这篇关于在ASP.NET code-背后推进向导的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆