开发者

Open an ASP.Net page containing a Wizard at a different WizardStep to the default starting step?

I've got an ASP.Net Forms page containing the following (simplified) <asp:Wizard /> control. I now need to modify this page so that when it is loaded, it loads showing the final step.

Is this possible to do without re-arranging the Wizard steps (Which I'd rather not do)?

<asp:UpdatePanel runat="server" ID="updpanHeader" UpdateMode="Conditional">
    <ContentTemplate>
        <asp:Wizard ID="Wizard1" runat="server" DisplaySideBar="false" 
          Style="width: 100%"
          Nav开发者_JS百科igationStyle-CssClass="invisible"
          OnNextButtonClick="Wizard1_NextButtonClick"
          OnActiveStepChanged="Wizard1_ActiveStepChanged">
            <WizardSteps>
                <asp:WizardStep ID="WizardStep1" runat="server" Title="Step 1"
                  StepType="Start">
                    ... wizard form controls for page 1 ...
                </asp:WizardStep>
                <asp:WizardStep ID="WizardStep2" runat="server" Title="Step 2"
                  StepType="Step">
                    ... wizard form controls for page 2 ...
                </asp:WizardStep>
                <asp:WizardStep ID="WizardStep3" runat="server" Title="Step 3"
                  StepType="Step">
                    ... wizard form controls for page 3 ...
                </asp:WizardStep>
            </WizardSteps>
        </asp:Wizard>
    </ContentTemplate>
</asp:UpdatePanel>

I've tried swapping the StepType of the first and last steps.

I've also tried changing the ActiveStepIndex in the Page_Load and Page_LoadComplete methods, which does work..

void Page_Load(object sender, EventArgs e)
{
    Wizard1.ActiveStepIndex = (Wizard1.WizardSteps.Count - 1);
}

..but causes Internet Explorer to show a script warning: "An error has occurred in the script on this page. Error: Object expected"

Thanks for your help!


I could be wrong, but I think you want to activate the index using an OnInit override, otherwise all post-backs are going to trigger the Page_Load.

Also, I believe you want to use the MoveTo command instead of setting the index. The downfall is you have to use the step's object, but you can get that easily from Wizard.WizardSteps I believe.

e.g.

private override void OnInit(EventArgs e)
{
  this.Wizard1.MoveTo(this.WizardStep3);

  base.OnInit(e);
}

I may be wrong here though... Please someone correct me if I am.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜