Setting focus to a textbox

Discussion in 'ASP .Net' started by Nick S, Nov 21, 2005.

  1. Nick S

    Nick S Guest

    When I validate data in a field, the form does a postback - and focus goes
    back to the first control. How do I change focus to a different textbox. I
    though texbox.focus or textbox.setfocus - but neither of these work...

    Thanks
    Nick S, Nov 21, 2005
    #1
    1. Advertising

  2. Nick S

    Rob Meade Guest

    "Nick S" wrote ...

    > When I validate data in a field, the form does a postback - and focus goes
    > back to the first control. How do I change focus to a different textbox. I
    > though texbox.focus or textbox.setfocus - but neither of these work...


    Hi Nick,

    You *could* spit out a scriptblock and write a javascript function to the
    page in the focus'ing the control of your choice, you'd need to write an
    "onload" attribute/value to the BODY tag also...

    Hope this helps..

    Regards

    Rob
    Rob Meade, Nov 21, 2005
    #2
    1. Advertising

  3. You could output some JavaScript, as in this example I put together:
    http://SteveOrr.net/faq/2in1.aspx

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


    "Nick S" <> wrote in message
    news:...
    > When I validate data in a field, the form does a postback - and focus goes
    > back to the first control. How do I change focus to a different textbox. I
    > though texbox.focus or textbox.setfocus - but neither of these work...
    >
    > Thanks
    >
    Steve C. Orr [MVP, MCSD], Nov 21, 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:
    588
    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,751
    Kevin Spencer
    Aug 30, 2003
  3. Jason
    Replies:
    4
    Views:
    1,618
    Jason
    May 7, 2007
  4. Replies:
    2
    Views:
    336
    Thomas 'PointedEars' Lahn
    Jun 6, 2005
  5. Roger
    Replies:
    3
    Views:
    322
Loading...

Share This Page