Home All Groups Group Topic Archive Search About

Easy one about web forms

Author
12 Apr 2005 2:33 PM
Ann Smith
How do you set the focus to a text box on a web form?  I
want it to go to different boxes depending on the answer
to a question.

Thanks
Ann

Author
12 Apr 2005 2:53 PM
Marcie Jones
Hi Ann,
You need the .focus() method in Javascript to do this.

Marcie

On Tue, 12 Apr 2005 07:33:30 -0700, "Ann Smith"
<anonym***@discussions.microsoft.com> wrote:

Show quoteHide quote
>
>How do you set the focus to a text box on a web form?  I
>want it to go to different boxes depending on the answer
>to a question.
>
>Thanks
>Ann
Author
12 Apr 2005 3:00 PM
Ann Smith
Is it not possible to do it in VB then?

Show quoteHide quote
>-----Original Message-----
>Hi Ann,
>You need the .focus() method in Javascript to do this.
>
>Marcie
>
>On Tue, 12 Apr 2005 07:33:30 -0700, "Ann Smith"
><anonym***@discussions.microsoft.com> wrote:
>
>>
>>How do you set the focus to a text box on a web form?  I
>>want it to go to different boxes depending on the answer
>>to a question.
>>
>>Thanks
>>Ann
>
>.
>
Author
12 Apr 2005 3:13 PM
Marcie Jones
For web forms you have to set focus with client-side script.  You can
emit the script from the server, with routines such as
RegisterStartupScript.

Marcie

On Tue, 12 Apr 2005 08:00:28 -0700, "Ann Smith"
<anonym***@discussions.microsoft.com> wrote:

Show quoteHide quote
>Is it not possible to do it in VB then?
>
>>-----Original Message-----
>>Hi Ann,
>>You need the .focus() method in Javascript to do this.
>>
>>Marcie
>>
>>On Tue, 12 Apr 2005 07:33:30 -0700, "Ann Smith"
>><anonym***@discussions.microsoft.com> wrote:
>>
>>>
>>>How do you set the focus to a text box on a web form?  I
>>>want it to go to different boxes depending on the answer
>>>to a question.
>>>
>>>Thanks
>>>Ann
>>
>>.
>>
Author
12 Apr 2005 3:38 PM
Cor Ligthert
Marcie,

> For web forms you have to set focus with client-side script.  You can
> emit the script from the server, with routines such as
> RegisterStartupScript.
>
However I never succeeded with this one, because it has to be absolute the
last on a page.

\\\
When this is your textbox (can as well be an ASP box it is the ID that
counts)
<INPUT tabindex="1"  id="fieldid" type="text" size="27">

//This should be the last rows in your html aspx file

<script language="JavaScript">
document.all("fieldid").focus();
</script>
</HTML>
///

I hope this helps a little bit?

Cor