how to access with code-behind a label embedded in CreateUserWizard control?

Last post 03-10-2007 8:59 AM by tartuffe2. 4 replies.

Sort Posts:

  • how to access with code-behind a label embedded in CreateUserWizard control?

    03-09-2007, 4:50 PM
    • Member
      144 point Member
    • tartuffe2
    • Member since 06-28-2006, 6:15 AM
    • Posts 433
    Hi,

    i have some problem to access from code-behind a label nested into a
    CreateWizard control. I use a html-table for align purpose only.
    I try to change the text property of the label with ID="UserNameLabel".

    <asp:CreateUserWizard ID="CreateUserWizard1" runat="server">
     <WizardSteps>
      <asp:CreateUserWizardStep runat="server">
          <ContentTemplate>
              <table border="0">
                 <tr><td>Make a new account</td></tr>
                 <tr><td><asp:Label ID="UserNameLabel"
    runat="server">Username:</asp:Label></td>
                     <td><asp:TextBox ID="UserName"
    runat="server"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="UserNameRequired"
    runat="server">*</asp:RequiredFieldValidator>
                 </td></tr>
               </table>
           </ContentTemplate>
      </asp:CreateUserWizardStep>
     </WizardSteps>
    </asp:CreateUserWizard>


    My attempt:
    ----------
    Dim lb As New Label
    lb = CreateUserWizard1.WizardSteps.Item(4)


    (I also tried with Item(0) till 6).

    Thanks for help
    T.
  • Re: how to access with code-behind a label embedded in CreateUserWizard control?

    03-09-2007, 9:10 PM
    • Participant
      1,025 point Participant
    • spvlong
    • Member since 04-17-2006, 2:29 AM
    • Posts 187

    Hi tartuffe2,

     Try this code

     

    Dim lbl As Label

    lbl = CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl(

    "UserNameLabel")
    www.stockbiz.vn
    The Vietnamese Stock Market and Economy
  • Re: how to access with code-behind a label embedded in CreateUserWizard control?

    03-10-2007, 4:52 AM
    • Member
      144 point Member
    • tartuffe2
    • Member since 06-28-2006, 6:15 AM
    • Posts 433

    Hi spvlong,

    thanks, it works.

    But i try to understand the logic of this code, and i would expect to mention each 'level' in the code:

    so, why is 'level' <Wizard> bypassed?

    Then you use  'CreateUserStep' (which is not even present in the file) instead of 'CreateUserWizardStep' ...

    Like i said, i would expect a logical sequence of all 'levels' before reaching the label ....

     

  • Re: how to access with code-behind a label embedded in CreateUserWizard control?

    03-10-2007, 5:21 AM
    Answer
    • Participant
      1,025 point Participant
    • spvlong
    • Member since 04-17-2006, 2:29 AM
    • Posts 187

    Hi tartuffe2,

     The CreateUserStep property return the CreateUserWizardStep object which contains the Label.

    You can also use the code below, it is more complicated but it is similar to your previous code.

    Dim lbl As Label

    Dim cuws As CreateUserWizardStep

    cuws =

    CType(CreateUserWizard1.WizardSteps.Item(0), CreateUserWizardStep)

    lbl = cuws.ContentTemplateContainer.FindControl(

    "UserNameLabel")
    www.stockbiz.vn
    The Vietnamese Stock Market and Economy
  • Re: how to access with code-behind a label embedded in CreateUserWizard control?

    03-10-2007, 8:59 AM
    • Member
      144 point Member
    • tartuffe2
    • Member since 06-28-2006, 6:15 AM
    • Posts 433
    Thanks a lot
Page 1 of 1 (5 items)