Could of field with autopostback - how to be able to set focus correctly.

Discussion in 'ASP .Net' started by Mufasa, Oct 4, 2007.

  1. Mufasa

    Mufasa Guest

    I have a couple of fields that are autopostback and I want to make tab work
    correctly between them. But whenever somebody changes the value and clicks
    somewhere else the page reloads as it should but there is no field with
    focus.

    So how can I tell what field the user clicked on before the page reloads,
    save that and set the focus to that field once they are done.

    TIA - J.
     
    Mufasa, Oct 4, 2007
    #1
    1. Advertising

  2. Mufasa

    Elroyskimms Guest

    On Oct 4, 11:33 am, "Mufasa" <> wrote:
    > I have a couple of fields that are autopostback and I want to make tab work
    > correctly between them. But whenever somebody changes the value and clicks
    > somewhere else the page reloads as it should but there is no field with
    > focus.
    >
    > So how can I tell what field the user clicked on before the page reloads,
    > save that and set the focus to that field once they are done.
    >
    > TIA - J.


    I don't think what you are looking for can be done without client
    scripting of some kind (Javascript). The PostBack will result in the
    page being redrawn and the tab position being reset to the 1st Control
    in the Control tree. In the OnChanged event (server-side), you could
    possibly use the ClientID attribute of the Texbox Controls and use
    response.write("<script language=javascript>SET FOCUS USING JAVASCRIPT
    HERE</script>").

    I've used something similar in the past but IE7 broke that code so I
    won't post it here. Actually, the code wasn't to standard so I can't
    blame IE7 for my bad programming :)

    Anyway, something like that should work but it may cause other
    problems and may not be cross-browser compatible... you'll want to
    check on that too.

    HTH,

    -E
     
    Elroyskimms, Oct 5, 2007
    #2
    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. Ben Fidge
    Replies:
    2
    Views:
    3,548
    Ben Fidge
    Jan 30, 2004
  2. Mad Scientist Jr
    Replies:
    2
    Views:
    5,290
    Mad Scientist Jr
    Jun 29, 2004
  3. sed_y
    Replies:
    0
    Views:
    1,024
    sed_y
    Feb 15, 2012
  4. Replies:
    2
    Views:
    343
    Thomas 'PointedEars' Lahn
    Jun 6, 2005
  5. Roger
    Replies:
    3
    Views:
    330
Loading...

Share This Page