[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

John Mims

1/3/2003 8:08:00 PM

Hello

I am trying to set the focus to a textbox (txtEmplId) control when a radio
button control (rbOtherSkills) is checked. I have attempted to use the
following in the PageLoad:
Dim sStartupString As String
sStartupString = "<script language=""JavaScript"">" & "document.forms[0]." &
txtEmplId.ClientID & ".focus();" & "</script>"

rbOtherSkills.Attributes.Add("onchange", sStartupString)

Thanks for your help.

John





1 Answer

(Patrick C. Cole (MS))

1/6/2003 10:15:00 PM

0

John,

Seems that you are close. Here is a C# sample that I created that does
allow for the TextBox to obtain focus:

RadioButton1.Attributes.Add("onclick", "document.forms[0]." +
TextBox1.ClientID.ToString() + ".focus();");

In this case we are just adding the onclick event attribute and the jscript
code necessary to set the focus of the textbox. Where this may fail would
be in the ClientID of the control. If the control is located within a
DataGrid or any templated control, the ClientID may contain a colon, which
may through the client-side code off. Give this a try and let me know if
this helps.

Patrick Cole
Microsoft Developer Communities

This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use. © 2002 Microsoft Corporation. All rights
reserved.
--------------------
| From: "John Mims" <jmims@arcadis-us.com>
| Subject: Set Focus to a Textbox control
| Date: Fri, 3 Jan 2003 12:08:14 -0700
| Lines: 19
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2600.0000
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
| Message-ID: <utUHRu1sCHA.1668@TK2MSFTNGP09>
| Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols
| NNTP-Posting-Host: 65.89.169.1
| Path: cpmsftngxa09!TK2MSFTNGP08!TK2MSFTNGP09
| Xref: cpmsftngxa09
microsoft.public.dotnet.framework.aspnet.webcontrols:8183
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols
|
| Hello
|
| I am trying to set the focus to a textbox (txtEmplId) control when a radio
| button control (rbOtherSkills) is checked. I have attempted to use the
| following in the PageLoad:
| Dim sStartupString As String
| sStartupString = "<script language=""JavaScript"">" &
"document.forms[0]." &
| txtEmplId.ClientID & ".focus();" & "</script>"
|
| rbOtherSkills.Attributes.Add("onchange", sStartupString)
|
| Thanks for your help.
|
| John
|
|
|
|
|
|