Setting focus of a control

G

Guest

Hi,

I have a textbox in which in the TextChanged event I check to make sure they
entered in valid data, however if the data isn't entered properly I want the
cursor to go back to that text so they can fix the error.

Any ideas on how to do this?

Regards
Brian
 
E

Eliyahu Goldin

Brian,

Add a hidden input and set it on the server side to the client id of the
control you want to set focus on. On client side, check the input in the
body's onload event and set the focus with

document.getElementById(hiddenInput.value).focus();

Eliyahu
 

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,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top