HELP: setting focus asp:textbox in a user control

Discussion in 'ASP General' started by Jesper Dannemamm, Dec 6, 2003.

  1. 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.user_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
    Jesper Dannemamm, Dec 6, 2003
    #1
    1. Advertising

  2. Jesper Dannemamm

    Evertjan. Guest

    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.user_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)
    Evertjan., Dec 6, 2003
    #2
    1. Advertising

  3. Jesper Dannemamm

    Steven Burn Guest

    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. <> wrote in message
    news:Xns9449B53EFF919eejj99@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.user_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)
    Steven Burn, Dec 6, 2003
    #3
  4. Re: setting focus asp:textbox in a user control

    > Page.RegisterStartupScript("focus", "<script
    >

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

    http://www.aspfaq.com/5002

    --
    Aaron Bertrand
    SQL Server MVP
    http://www.aspfaq.com/
    Aaron Bertrand [MVP], Dec 6, 2003
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. George Durzi

    Setting Focus on an asp:textbox

    George Durzi, Aug 20, 2003, in forum: ASP .Net
    Replies:
    4
    Views:
    587
    Marina
    Aug 20, 2003
  2. =?Utf-8?B?Q0xFQVItUkNJQw==?=

    setting focus to an asp.net web user control

    =?Utf-8?B?Q0xFQVItUkNJQw==?=, Dec 6, 2004, in forum: ASP .Net
    Replies:
    12
    Views:
    6,119
    Patrick Olurotimi Ige
    Dec 7, 2004
  3. =?Utf-8?B?U3JpZGhhcg==?=

    setting the focus to a textbox in a user control

    =?Utf-8?B?U3JpZGhhcg==?=, Feb 10, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    2,774
    Ton Strankinga
    Feb 10, 2006
  4. Jason
    Replies:
    4
    Views:
    1,617
    Jason
    May 7, 2007
  5. Roger
    Replies:
    3
    Views:
    321
Loading...

Share This Page