ASP.NET reserves the right to mangle IDs wherever it deems it appropriate.
When you open your page, go to view -> source and look for the <input
type="text" /> that is rendered for the control you are trying to set the
focus on, and then use this value. Alternately, an even better solution is
to have your server response.write the UniqueID of this control, which
guarantees that future name mangling schemes of the web controls will not
break your script.
--
Chris Jackson
Software Engineer
Microsoft MVP - Windows Client
Windows XP Associate Expert
--
More people read the newsgroups than read my email.
Reply to the newsgroup for a faster response.
(Control-G using Outlook Express)
--
"Renuka Srivastava" <re**************@hotmail.com> wrote in message
news:uB**************@TK2MSFTNGP12.phx.gbl...
How can I use it in ASP.net I tried the following javascript in the head
of Login.aspx
<script language="Javascript">
function setFocus()
{
document.forms.txtLogin.focus();
}
</script>
where txtLogin is the id of the asp:Label. And then calling this
function in the body.
<body onLoad="setFocus()">
Please help it gives an error on the line
document.forms.txtLogin.focus();
The error is : Microsoft JScript runtime error:
'document.forms.txtLogin' is null or not an object
Thanks for your help.
Renuka
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!