Prevent Navigation to CreateUserWizardStep in the Postback event of nextbutton

瘦欲@ 提交于 2019-12-12 04:07:33

问题


I am working with CreateUserWizard tool for creating a registration page. This is the first time and I am encountering problem with the following:

I defined two steps in WizardSteps in the page:

 <WizardSteps>
            <asp:WizardStep ID="CreateUserWizardStep0" runat="server" Title="Sign Up for your new Account !!">

    <asp:TextBox ID="Email" runat="server">

In the first wizard step, the user provides email, and we need to check if this email meets certain criteria (if he exists in our internal database, country is US etc) and if he/she is eligible navigate to CreateUserWizardStep1.

I have a StartNextButton in the Start Navigation template for the WizardStep0.

<StartNavigationTemplate>
        <br />
        <asp:Button ID="StartNextButton" runat="server" CommandName="MoveNext" OnClick="StartNextButton_Click"
            Text="Check My Eligibility" />
    </StartNavigationTemplate>

I do all the logic of checking eligibility in the post-back event OnClick="StartNextButton_Click . If he is not eligible, I should display the error message in the step0 textbox and prevent navigation to CreateUserWizardStep1.

I tried the following:

if(noteligible)
{
                    lblError1.Visible = true;
                    lblError1.Text = this.hfUserAlreadyRegistered.Value.ToString();
                    this.CreateUserWizard1.ActiveStepIndex = this.CreateUserWizard1.WizardSteps.IndexOf(this.CreateUserWizardStep0);
                    this.CreateUserWizard1.Controls.Remove(CreateUserWizardStep1);
                    this.CreateUserWizard1.ActiveStepIndex = 0;
                    break;

}

But this is not working. I am taken out of step0 and step1 is coming irrespective of this.

How can I just remain in Step0 and display the error message when the user is not eligible and navigate to Step1 only when he is eligible to register ?

Thank you very much.


回答1:


TRY TO:

this.CreateUserWizard1.ActiveStepIndex = -1;


来源:https://stackoverflow.com/questions/2763046/prevent-navigation-to-createuserwizardstep-in-the-postback-event-of-nextbutton

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!