How to programatically set focus onto a web control ?

N

news.iq.ca

Hi,

I have a form containing a number of panels, simulating a wizard
(simulating, actually, a multi-page form). After pressing a button called
"Next", I am showing a new panel on this form, loaded with some controls. I
need to set the focus onto a textbox in the newly shown panel right away,
without "asking" the user to tab (or to click) his way towards my textbox.
So please, how can I set the focus programatically on any control on my form
?

Maybe using "FindControl" ?? And then ?

Thank you
Alex
 
D

David Jessee

in the button's handler, put something like...
me.RegisterClientStartupScript("initialFocus","<script
language=javascript>document.Form1.theControlYouWant.focus();</script>")

be careful. If your text box us called text1 and its inside panel1 then the
clientID might be something like panel1:text1

You'll want to either do a View>>Source on your HTML to see what the client
ID is, or use the Test Box's ClientID property
 

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

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top