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

M

Mufasa

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.
 
E

Elroyskimms

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,992
Messages
2,570,220
Members
46,805
Latest member
ClydeHeld1

Latest Threads

Top