Programmatically switch to CompleteWizardStep in CreateUserWizard control
How do I programmatically switch to the asp:CompleteWizardStep
step in the OnCreatingUser
event in the asp:CreateUserWizard
control?
ASP.NET web form
<asp:CreateUserWizard ID="MyCreateUserWizard" runat="server" OnCreatingUser="MyCreateUserWizard_CreatingUser">
<WizardSteps>
<asp:CreateUserWizardStep ID="CreateUserStep1" runat="server">
<!-- code here -->
</asp:Create开发者_Go百科UserWizardStep>
<asp:CompleteWizardStep ID="CompleteWizardStep" runat="server">
<!-- code here -->
</asp:CompleteWizardStep>
</WizardSteps>
</asp:CreatedWizardStep>
Code behind
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
}
protected void CreateUserWizard1_CreatingUser(object sender, LoginCancelEventArgs e)
{
CreateUserWizard1.MoveTo(CompleteWizardStep1);
}
I just recreated your solution in VS2008 / .net 3.5 using the empty OnCreatingUser event handler and it "works on my computer". So, what's different that could be causing this problem?
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>
Code-behind:
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" />
Video of it working: http://www.screentoaster.com/watch/stWEJSR0ZIR19YRVleWV9QXlJX
精彩评论