By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,687 Members | 2,065 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,687 IT Pros & Developers. It's quick & easy.

HELP: setting focus asp:textbox in a user control

P: n/a
Hi

I am having trouble setting focus on

I tried using this script in the usercontrol's page_load sub to set focus on
a textbox with the ID = "user_name":
Page.RegisterStartupScript("focus", "<script
language=""JavaScript"">document.getElementById.us er_name.focus();</script>
")

I get an error message saying that the textbox is null or not an object.

What am I doing wrong??

Regards
Jesper
Jul 19 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Jesper Dannemamm wrote on 06 dec 2003 in
microsoft.public.inetserver.asp.general:
I am having trouble setting focus on

I tried using this script in the usercontrol's page_load sub to set
focus on a textbox with the ID = "user_name":
Page.RegisterStartupScript("focus", "<script
language=""JavaScript"">document.getElementById.us er_name.focus();</scr
ipt> ")

I get an error message saying that the textbox is null or not an
object.

What am I doing wrong??


ASP is serverside so does not know about focus.

Perhaps this is a ASP.NET thing, but this NG is for classical asp.

Please see a clientside javascript NG or perhaps a dotnet NG.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Jul 19 '05 #2

P: n/a
Can't you use something alone the line's of..;

<%
If user_name="" Then
url = "focus.asp?reqd=* indicates required field&name=" & name
If name="" Then
'muser_name = the texbox name
url = url & "&user_name=*"
End if

response.redirect url & "&foobar=foobar#form"
response.end
End if
%>

--

Regards

Steven Burn
Ur I.T. Mate Group
www.it-mate.co.uk

Keeping it FREE!

Disclaimer:
I know I'm probably wrong, I just like taking part ;o)
Evertjan. <ex**************@interxnl.net> wrote in message
news:Xn********************@194.109.133.29...
Jesper Dannemamm wrote on 06 dec 2003 in
microsoft.public.inetserver.asp.general:
I am having trouble setting focus on

I tried using this script in the usercontrol's page_load sub to set
focus on a textbox with the ID = "user_name":
Page.RegisterStartupScript("focus", "<script
language=""JavaScript"">document.getElementById.us er_name.focus();</scr
ipt> ")

I get an error message saying that the textbox is null or not an
object.

What am I doing wrong??


ASP is serverside so does not know about focus.

Perhaps this is a ASP.NET thing, but this NG is for classical asp.

Please see a clientside javascript NG or perhaps a dotnet NG.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

Jul 19 '05 #3

P: n/a
> Page.RegisterStartupScript("focus", "<script

language=""JavaScript"">document.getElementById.us er_name.focus();</script>

http://www.aspfaq.com/5002

--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/
Jul 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.