在nextbutton的回发事件中阻止导航到CreateUserWizardStep [英] Prevent Navigation to CreateUserWizardStep in the Postback event of nextbutton

查看:96
本文介绍了在nextbutton的回发事件中阻止导航到CreateUserWizardStep的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用CreateUserWizard工具来创建注册页面.这是第一次,我遇到以下问题:

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

我在页面的WizardSteps中定义了两个步骤:

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

在向导的第一步中,用户提供电子邮件,我们需要检查此电子邮件是否满足某些条件(如果他存在于我们的内部数据库中,国家/地区是美国等),并且他/她是否有资格导航到CreateUserWizardStep1.

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.

我在WizardStep0的开始导航"模板中有一个StartNextButton.

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>

我会执行所有在回发事件中检查资格的逻辑 OnClick ="StartNextButton_Click .如果他不符合资格,我应该在step0文本框中显示错误消息,并防止导航到CreateUserWizardStep1

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.

我尝试了以下操作:

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;

}

但是这不起作用.无论如何,我都退出了step0,而step1即将来临.

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

如果用户不符合条件,我如何只留在Step0中并显示错误消息,而只有当他符合条件时,才可以导航至Step1?

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 ?

非常感谢您.

推荐答案

尝试:

this.CreateUserWizard1.ActiveStepIndex = -1;

这篇关于在nextbutton的回发事件中阻止导航到CreateUserWizardStep的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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