Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > How to programatically set focus onto a web control ?

Reply
Thread Tools

How to programatically set focus onto a web control ?

 
 
news.iq.ca
Guest
Posts: n/a
 
      11-26-2004
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


 
Reply With Quote
 
 
 
 
David Jessee
Guest
Posts: n/a
 
      11-26-2004
in the button's handler, put something like...
me.RegisterClientStartupScript("initialFocus","<sc ript
language=javascript>document.Form1.theControlYouWa nt.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

"news.iq.ca" <(E-Mail Removed)> wrote in message
news:41a6dde4_2@aeinews....
> 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
>
>



 
Reply With Quote
 
 
 
 
Ken Cox [Microsoft MVP]
Guest
Posts: n/a
 
      11-26-2004
Hi Alex,

You might want to investigate this free control:

FirstFocus Control
This control creates the proper javascript to give focus to control after
the page has loaded.

http://www.metabuilders.com/Tools/FirstFocus.aspx

"news.iq.ca" <(E-Mail Removed)> wrote in message
news:41a6dde4_2@aeinews....
> 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
>


 
Reply With Quote
 
news.iq.ca
Guest
Posts: n/a
 
      12-02-2004
Thanks a lot for your answers. ))

Alex.

"news.iq.ca" <(E-Mail Removed)> wrote in message
news:41a6dde4_2@aeinews....
> 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
>



 
Reply With Quote
 
Ryan De Laet
Guest
Posts: n/a
 
      12-16-2004
Try here:
http://lucaslabs.net/blogs/mcculloch...07/23/875.aspx

"news.iq.ca" <(E-Mail Removed)> wrote in message
news:41aea2ec_4@aeinews....
> Thanks a lot for your answers. ))
>
> Alex.
>
> "news.iq.ca" <(E-Mail Removed)> wrote in message
> news:41a6dde4_2@aeinews....
> > 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
> >

>
>



 
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
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
this.window.focus() vs. window.focus() vs. this.focus() Roger Javascript 3 03-08-2007 08:53 PM
Why does putting focus on textbox also set focus to submit jw56578@gmail.com Javascript 2 06-06-2005 08:20 PM
Photo quality - onto paper or onto CD? Theseeker Digital Photography 8 10-04-2004 08:59 PM
Position Web control within Panel on Web Form ... programatically M- ASP .Net 1 07-09-2003 08:57 PM



Advertisments