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
You may try to do the following:
-Register two scripts (one to create a function to focus on your texbox when page is displayed, second to register id of the textbox)
As the result you should get the following in your code:
I'm using Page.Form.DefaultFocus and it works:
None of the above answers worked for me, so I simply tried:
... and it worked!
With an ASP TextBox defined as:
Are you using a ScriptManager on the Page? If so, try the following:
Update: Never used a multiview before, but try this: