Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4577236
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T20:19:05+00:00 2026-05-21T20:19:05+00:00

i have a login control and a create user control i my web page…i

  • 0

i have a login control and a create user control i my web page…i want the cursor to be in the user name text box of the login control when the page loads…how can i do that??

<asp:LoginView ID="LoginView1" runat="server">
              <LoggedInTemplate>
                  Bingo..!!! Youuuuu did it...<asp:LoginName ID="LoginName1" runat="server" />.



              </LoggedInTemplate>
              <AnonymousTemplate>

                  <asp:DropShadowExtender ID="DropShadowExtender1" runat="server" 
                                            TargetControlID="Panel1" 
                                            Rounded="true" 
                                            Opacity=".38">
                  </asp:DropShadowExtender>
                  <asp:Panel ID="Panel1" runat="server" 
                                         BackColor="Silver">
                  <asp:Login ID="Login1" runat="server" 
                                         DestinationPageUrl="~/ViewCart_aspx/ViewCart.aspx" 
                                         Height="152px" 
                                         Width="396px" 
                                         RememberMeSet="True" 
                                         OnLoggedIn="ContinueButton_Click" >
                      <LayoutTemplate>
                          <fieldset>
                          <table border="0" 
                                 cellpadding="1" 
                                 cellspacing="0" 
                                 style="border-collapse:collapse;">
                              <tr>
                                  <td>
                                      <table border="0" cellpadding="0" style="height:152px;width:396px;">
                                          <tr>
                                              <td align="center" colspan="2">
                                                 <h3>Log In</h3> </td>
                                          </tr>
                                          <tr>
                                              <td align="right">
                                                  <asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName">User Name:</asp:Label>
                                              </td>
                                              <td>&nbsp;
                                                  <asp:TextBox ID="UserName" runat="server" Width="150px" TabIndex="0"></asp:TextBox>
                                                  <asp:RequiredFieldValidator ID="UserNameRequired" runat="server" 
                                                      ControlToValidate="UserName" ErrorMessage="User Name is required." 
                                                      ToolTip="User Name is required." ValidationGroup="ctl01$Login1">*</asp:RequiredFieldValidator>
                                              </td>
                                          </tr>

as u can see the UserName textbox is inside the login control..so i cannot access its property..how do i find the control??

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T20:19:05+00:00Added an answer on May 21, 2026 at 8:19 pm

    EDIT: as you mentioned in comments, you want to set your login button to be clicked as a default button. For this you need to set this button as a default button.

    Unfortunatelly, you didn’t format you code properly as I asked in a comment to your question. So I assume the login button is located in the same name container as the username text box and its name is btnLogin and you could set this control as a default control with HtmlForm.DefaultButton property, so:

    You could use Page.SetFocus for this. It sets the browser focus to the specified control:

    Page.SetFocus(txtName);
    

    If you want to reach your UserName textbox, you could use just:

    var login1 = LoginView1.FindControl("Login1") as Login;
    if (login1 != null)
    {
        var txtUserName = login1.FindControl("UserName");
        if (txtUserName != null)
        {
            Page.SetFocus(txtUserName);
        }
    
        var btnLogin = login1.FindControl("btnLogin");
        if (btnLogin != null) 
        {
             Page.Form.DefaultButton = btnLogin.UniqueID;
        }
    }
    

    But note:

    For the LoginView control, when being
    added onto a page, at a certain time,
    only one Template (anonymous or
    loggedIn ) is applied on the Control
    instance, so at that time, we can only
    retrieve the reference of those
    controls in the active template( can’t
    access those in the non-active
    template).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to create login user control in asp.net mvc site , to be
I have a Login control login1. When an user login his username and password,
In my page I have a login control: <asp:Login ID=EMSLogin runat=server OnAuthenticate=EMSLogin_Authenticate> <LayoutTemplate> <asp:Panel
I have an ASP.NET login control on a page, with the Remember Me checkbox
I have a createuserwizard and a login control on a page. both of them
on my web site I want to have login/registration form in modal window done
I have an ASP.NET WebForms page with forms authentication. When users create a login,
I will create an ASP.NET Web Application like this; Users can login their own
I have created a website and I want to create a control panel for
I have the following code for my login view: <?php echo $session->flash('auth'); echo $this->Form->create('User',

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.