.NET Framework Developer Center > .NET Development Forums > JScript for the .NET Framework > ClientID of a textbox in ContentTemplate of CreateUserWizardStep
Ask a questionAsk a question
 

AnswerClientID of a textbox in ContentTemplate of CreateUserWizardStep

  • Friday, November 06, 2009 1:26 PMUsha2009 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     

    Hi!

    I have a testbox in an .ascx file. The code is below.

    <asp:CreateUserWizard ID="CreateUserWizard1" runat="server" OnCreatedUser="CreateUserWizard_CreatedUser" RequireEmail="false">
                <WizardSteps>
                    <asp:CreateUserWizardStep ID="CreateUserWizardStep1" runat="server">
                        <ContentTemplate>
                            <asp:Literal ID="ErrorMessage" runat="server" EnableViewState="False" /><br />
                            <fieldset class="mscs-formInputs">
                                <table id="Table1">
    <tr>
    <td>
    <asp:TextBox ID="FirstName" Text="First Name" runat="server" MaxLength="100"  />
    </td>
    </tr>
    </tr>
    </table>
    </fieldset>
    </ContentTemplate>
     </asp:CompleteWizardStep>
     </WizardSteps>
            </asp:CreateUserWizard>

    in the code behind .ascx.cs file the FirstName is accessed as below.
    TextBox firstNameControl = this.CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("FirstName") as TextBox;

    If I directly access FisrtName in the codebehind. It is giving null, so I am accessing by the above way.

    in the ascx file I want to access the ClientID of the FirstName, how can I access it.

    in general we access as say if there is an ordinary textbox in a simple table control we access as below.

    <script type="text/javascript">
      var txtUsernameID = '<%= txtUsername.ClientID %>';

    I want to know how I can access "FirstName" textbox which is in a CreateUserWizard.

    I appreciate your help.

    Thanks and regards,
    Usha.

Answers

  • Monday, November 09, 2009 9:42 AMJi.ZhouMSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    Hello Usha,


    We should enable the  "Customize Create User Step" before we can get the Textbox using FindControl, see Nai-Dong Jin's reply here,
    http://forums.asp.net/t/1175378.aspx

    And we should make sure we use the right name for that textbox. Your codes look fine to  me.

    By the way, this question is more at ASP.NET site instead of JScript. So if you need future help, trying to post in ASP.NET forum may let you get more ASP.NET experts' responses.

    http://forums.asp.net/145.aspx
    Have a nice day!
     

    Ji Zhou

    MSDN Subscriber Support in Forum

    If you have any feedback on our support, please contact msdnmg@microsoft.com


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    • Marked As Answer byUsha2009 Wednesday, November 11, 2009 1:22 AM
    •  

All Replies

  • Monday, November 09, 2009 9:42 AMJi.ZhouMSFT, ModeratorUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer

    Hello Usha,


    We should enable the  "Customize Create User Step" before we can get the Textbox using FindControl, see Nai-Dong Jin's reply here,
    http://forums.asp.net/t/1175378.aspx

    And we should make sure we use the right name for that textbox. Your codes look fine to  me.

    By the way, this question is more at ASP.NET site instead of JScript. So if you need future help, trying to post in ASP.NET forum may let you get more ASP.NET experts' responses.

    http://forums.asp.net/145.aspx
    Have a nice day!
     

    Ji Zhou

    MSDN Subscriber Support in Forum

    If you have any feedback on our support, please contact msdnmg@microsoft.com


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    • Marked As Answer byUsha2009 Wednesday, November 11, 2009 1:22 AM
    •  
  • Wednesday, November 11, 2009 1:26 AMUsha2009 Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hi! Ji Zhou,

    Thanks for your reply. Now it is working for me as you had rightly suggeted in the forum link, I had casted the textbox and got lits ClientID as below.

    var FirstNameClientID ='<%= (TextBox)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("FirstName").ClientID %>';

    Have a nice day.
    Thanks and regards,
    Usha.