C# 如何在Asp.Net中处理CreateUserWizard步骤?

C# 如何在Asp.Net中处理CreateUserWizard步骤?,c#,asp.net,sql-server,C#,Asp.net,Sql Server,我在项目中使用了asp.net creatuserwizard。我的自定义模板如下所示 <WizardSteps> <asp:CreateUserWizardStep ID="CreateUserWizardStep0" runat="server"> <ContentTemplate> //my custom code is here </ContentTemplate>

我在项目中使用了asp.net creatuserwizard。我的自定义模板如下所示

<WizardSteps>
    <asp:CreateUserWizardStep ID="CreateUserWizardStep0" runat="server">
        <ContentTemplate>
          //my custom code is here
        </ContentTemplate>
        <CustomNavigationTemplate>
        </CustomNavigationTemplate>
    </asp:CreateUserWizardStep>

//我的自定义代码在这里
现在,在步骤2中,我有这样的代码

 <asp:WizardStep ID="CreateUserWizardStep1" runat="server" AllowReturn="False"             StepType="Step">
        <div class="accountInfo">
            <fieldset class="register">
                   <p>
                        <asp:Label ID="CityLabel" runat="server" AssociatedControlID="City">City:</asp:Label>
                        <asp:TextBox ID="City" runat="server" CssClass="textEntry"></asp:TextBox>
                    </p>
                    <p>
                        <asp:Label ID="CountryLabel" runat="server" AssociatedControlID="Country">Country:</asp:Label>
                        <asp:TextBox ID="Country" runat="server" CssClass="textEntry"></asp:TextBox>
                    </p>

            </fieldset>
        </div>
    </asp:WizardStep>


城市:

国家:


因此,我的问题是,当我在第2步单击“下一步”时,如何在我的用户配置文件中插入“城市”文本框值。

您需要添加代码来处理向导控件的
CreatedUser
事件

此部分应位于代码隐藏中,您可以在其中访问向导的当前状态:

protected void CreateUserWizard_CreatedUser(object sender, EventArgs e)
{
  // Finde the value
  var cityField = (TextBox)CreateUserWizard.CreateUserWizardStep1.FindControl("City");

  // use the field value todo whatever you want    
}

您需要添加代码来处理向导控件的
CreatedUser
事件

此部分应位于代码隐藏中,您可以在其中访问向导的当前状态:

protected void CreateUserWizard_CreatedUser(object sender, EventArgs e)
{
  // Finde the value
  var cityField = (TextBox)CreateUserWizard.CreateUserWizardStep1.FindControl("City");

  // use the field value todo whatever you want    
}

您可以处理创建用户向导的NextButtonClick并检查currentstepindex:

    protected void YourCreateUserWizard_NextButtonClick(object sender, WizardNavigationEventArgs e)
    {
        if (e.CurrentStepIndex == YourStepIndex)
        {
            ...
        }
    }

您可以处理创建用户向导的NextButtonClick并检查currentstepindex:

    protected void YourCreateUserWizard_NextButtonClick(object sender, WizardNavigationEventArgs e)
    {
        if (e.CurrentStepIndex == YourStepIndex)
        {
            ...
        }
    }

我读过这篇文章,但是它说所有的东西都是在第一步i-e中创建的,而我想处理写在里面的代码,我读过这篇文章,但是它说所有的东西都是在第一步i-e中创建的,而我想处理写在里面的代码,我也试过这篇文章。此代码不保存配置文件设置i-e City。我的代码只有在步骤0中声明cityTextbox并像这样调用我的代码时才有效;var cityField=(TextBox)CreateUserWizard.CreateUserWizardStep0.ContainerTemplate.FindControl(“城市”);我也试过这个。此代码不保存配置文件设置i-e City。我的代码只有在步骤0中声明cityTextbox并像这样调用我的代码时才有效;var cityField=(TextBox)CreateUserWizard.CreateUserWizardStep0.ContainerTemplate.FindControl(“城市”);