Setting focus to TextBox

Discussion in 'ASP .Net Web Controls' started by Simon Cheng, Nov 26, 2005.

  1. Simon Cheng

    Simon Cheng Guest

    Hi,,

    Is there a way to set focus to an System.Web.UI.WebControls.TextBox control
    on a web form? The class doesn't seem to provide such facility? Basically I
    want to set input cursor to a TextBox when the page is first loaded or after
    the user submit invalid data.

    Thanks,
    - Simon
    Simon Cheng, Nov 26, 2005
    #1
    1. Advertising

  2. You can set focus to a particular control with the Javascript "focus"
    method.

    In ASP.NET 2.0 its even easier.

    Here are all the details:
    http://SteveOrr.net/faq/2in1.aspx

    --
    I hope this helps,
    Steve C. Orr, MCSD, MVP
    http://SteveOrr.net


    "Simon Cheng" <> wrote in message
    news:...
    > Hi,,
    >
    > Is there a way to set focus to an System.Web.UI.WebControls.TextBox
    > control on a web form? The class doesn't seem to provide such facility?
    > Basically I want to set input cursor to a TextBox when the page is first
    > loaded or after the user submit invalid data.
    >
    > Thanks,
    > - Simon
    >
    Steve C. Orr [MVP, MCSD], Nov 27, 2005
    #2
    1. Advertising

  3. Simon Cheng

    Simon Cheng Guest

    Thanks! ASP.NET 2.0's DefaultButton only supports (well) Button control. Is
    there an equivalent for TextBox control?

    -Simon

    "Steve C. Orr [MVP, MCSD]" <> wrote in message
    news:e%...
    > You can set focus to a particular control with the Javascript "focus"
    > method.
    >
    > In ASP.NET 2.0 its even easier.
    >
    > Here are all the details:
    > http://SteveOrr.net/faq/2in1.aspx
    >
    > --
    > I hope this helps,
    > Steve C. Orr, MCSD, MVP
    > http://SteveOrr.net
    >
    >
    > "Simon Cheng" <> wrote in message
    > news:...
    >> Hi,,
    >>
    >> Is there a way to set focus to an System.Web.UI.WebControls.TextBox
    >> control on a web form? The class doesn't seem to provide such facility?
    >> Basically I want to set input cursor to a TextBox when the page is first
    >> loaded or after the user submit invalid data.
    >>
    >> Thanks,
    >> - Simon
    >>

    >
    >
    Simon Cheng, Nov 27, 2005
    #3
    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:
    571
    Marina
    Aug 20, 2003
  2. test test

    setting focus to a textbox

    test test, Aug 30, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    1,735
    Kevin Spencer
    Aug 30, 2003
  3. Jason
    Replies:
    4
    Views:
    1,587
    Jason
    May 7, 2007
  4. Replies:
    2
    Views:
    325
    Thomas 'PointedEars' Lahn
    Jun 6, 2005
  5. Roger
    Replies:
    3
    Views:
    302
Loading...

Share This Page