Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Setting focus of a control

Reply
Thread Tools

Setting focus of a control

 
 
=?Utf-8?B?YmJkb2J1ZGR5?=
Guest
Posts: n/a
 
      08-01-2005
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
 
Reply With Quote
 
 
 
 
Eliyahu Goldin
Guest
Posts: n/a
 
      08-01-2005
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

"bbdobuddy" <> wrote in message
news:7BD5767C-096A-4434-B202-...
> 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



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
emulating window.focus in Body onload() event and setting focus to a control on same page Jason ASP .Net 4 05-07-2007 05:54 PM
this.window.focus() vs. window.focus() vs. this.focus() Roger Javascript 3 03-08-2007 08:53 PM
setting focus to an asp.net web user control =?Utf-8?B?Q0xFQVItUkNJQw==?= ASP .Net 12 12-07-2004 02:29 AM
Setting focus on control Mike ASP .Net 2 08-11-2004 03:41 AM
Setting Focus on control after Validation Vinod I ASP .Net 2 02-04-2004 08:14 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57