Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>EDIT:</strong> as you mentioned in comments, you want to set your <em>login button to be clicked as a default button</em>. For this you need to set this button as a <em>default</em> button. </p> <p>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 <code>btnLogin</code> and you could set this control as a default control with <code>HtmlForm.DefaultButton</code> property, so:</p> <p>You could use <a href="http://msdn.microsoft.com/en-us/library/e04ah0f4.aspx" rel="nofollow"><code>Page.SetFocus</code></a> for this. It sets the browser focus to the specified control:</p> <pre><code>Page.SetFocus(txtName); </code></pre> <p>If you want to reach your <code>UserName</code> textbox, you could use just:</p> <pre><code>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; } } </code></pre> <p>But note:</p> <blockquote> <p>For the <code>LoginView</code> control, when being added onto a page, at a certain time, only one <code>Template</code> (anonymous or loggedIn ) is applied on the <code>Control</code> 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).</p> </blockquote>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload