以编程方式切换到CreateUserWizard控件中的CompleteWizardStep

时间:2010-02-25 17:28:49

标签: c# asp.net-membership createuserwizard

如何以编程方式切换到asp:CompleteWizardStep控件中OnCreatingUser事件中的asp:CreateUserWizard步骤?

ASP.NET网络表单

<asp:CreateUserWizard ID="MyCreateUserWizard" runat="server" OnCreatingUser="MyCreateUserWizard_CreatingUser">
    <WizardSteps>
        <asp:CreateUserWizardStep ID="CreateUserStep1" runat="server">
            <!-- code here -->
        </asp:CreateUserWizardStep>
        <asp:CompleteWizardStep ID="CompleteWizardStep" runat="server">
            <!-- code here -->
        </asp:CompleteWizardStep>
    </WizardSteps>
</asp:CreatedWizardStep>

背后的代码

protected void MyCreateUserWizard_CreatingUser(object sender, EventArgs e)
{
    //retrieve username, password and email

    Membership.CreateUser(username, password, email);

    //would like to display the CompleteWizardStpe here

}

2 个答案:

答案 0 :(得分:0)

protected void CreateUserWizard1_CreatingUser(object sender, LoginCancelEventArgs e)
{
    CreateUserWizard1.MoveTo(CompleteWizardStep1);
}

答案 1 :(得分:0)

我刚刚使用空OnCreatingUser事件处理程序在VS2008 / .net 3.5中重新创建了您的解决方案,它“可以在我的计算机上运行”。那么,可能导致这个问题的不同之处是什么?

ASPX:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default"
    Trace="false" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<body>
    <form id="form1" runat="server">
    <asp:CreateUserWizard ID="CreateUserWizard1" runat="server" OnCreatingUser="CreateUserWizard1_CreatingUser">
        <WizardSteps>
            <asp:CreateUserWizardStep ID="CreateUserWizardStep1" runat="server">
            </asp:CreateUserWizardStep>
            <asp:CompleteWizardStep ID="CompleteWizardStep1" runat="server">
            </asp:CompleteWizardStep>
        </WizardSteps>
    </asp:CreateUserWizard>
    </form>
</body>
</html>

代码隐藏:

namespace WebApplication1
{
    public partial class _Default : System.Web.UI.Page
    {
        protected void CreateUserWizard1_CreatingUser(object sender, System.Web.UI.WebControls.LoginCancelEventArgs e)
        {
        }
    }
}

的web.config:

<authentication mode="Forms" />

正在运行的视频:http://www.screentoaster.com/watch/stWEJSR0ZIR19YRVleWV9QXlJX