2012-02-28 89 views
1

我在我的項目中使用了asp.net creatuserwizard。我的自定義模板看起來像這樣如何處理Asp.Net中的CreateUserWizard步驟?

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

所以,我的問題是,如何插入我的用戶配置文件「城市」文本框的值,因爲我在接下來的第二步點擊。

+0

我已經讀過這個,但它說,一切都是在第一步創建的,即「」,而我想處理寫在 2012-02-28 15:43:21

回答

1

您可以處理創建用戶嚮導的NextButtonClick並檢查currentstepindex:

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

您將需要添加代碼來處理嚮導控件的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  
} 
+0

的代碼我也試過這個。此代碼不保存配置文件設置i-e City。我的代碼只適用於如果我在step0中聲明cityTextbox並像這樣調用我的代碼; _var cityField =(TextBox)CreateUserWizard.CreateUserWizardStep0.ContainerTempalate.FindControl(「City」); _ – 2012-02-28 16:43:41

相關問題