Set focus to textbox in ASP.NET Login control on page load.

Posted by anD666 on Stack Overflow See other posts from Stack Overflow or by anD666
Published on 2010-06-15T08:26:29Z Indexed on 2010/06/15 9:32 UTC
Read the original article Hit count: 279

Filed under:
|
|
|

Hiya,

I am trying to set the focus to the user name TextBox which is inside an ASP.NET Login control.

I have tried to do this a couple of ways but none seem to be working. The page is loading but not going to the control.

Here is the code I've tried.

SetFocus(this.loginForm.FindControl("UserName"));

And

TextBox tbox = (TextBox)this.loginForm.FindControl("UserName");
if (tbox != null)
{    
  tbox.Focus();
} // if

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about login