G
George Durzi
I'm trying to set focus on an asp:textbox. I'm running this code after my
page_load
StringBuilder sb = new StringBuilder();
sb.Append(@"<script language=javascript>");
sb.Append(@"<!--");
sb.Append(@"document.getElementById(txtUserName).focus();");
sb.Append(@"-->");
sb.Append(@"</script>");
if (!IsStartupScriptRegistered("LoginFocus"))
RegisterStartupScript("LoginFocus", sb.ToString());
If I View Source, I can confirm that the JavaScript is being outputed before
the </form> tag, but my control is not getting focus ...
Any idea?
page_load
StringBuilder sb = new StringBuilder();
sb.Append(@"<script language=javascript>");
sb.Append(@"<!--");
sb.Append(@"document.getElementById(txtUserName).focus();");
sb.Append(@"-->");
sb.Append(@"</script>");
if (!IsStartupScriptRegistered("LoginFocus"))
RegisterStartupScript("LoginFocus", sb.ToString());
If I View Source, I can confirm that the JavaScript is being outputed before
the </form> tag, but my control is not getting focus ...
Any idea?