I have a page with a drop down and several web controls. The drop down
is set to postback and it reloads the textboxes based on the selected
drop down item. I set the focus to the first textbox control on the
client like this:
<script language="vbscript">
Option Explicit
...other code
If Not <%=mbReadOnly%> Then
document.frmDetails.txtName.focus()
End If
...other code
</script>
This works fine on first page load but when I change the drop down it
does reset the focus and you can't even type in the first textbox
until you select another textbox first.
To debug I added a message box right before the set focus to see if it
was even getting to this line of code and it works but I can't leave a
message box here.
Any ideas on what could be the problem?
Thanks in advance for any help,
DeidreHi
setfocus in body onload event,
document.frmDetails.txtName.focus()
HTH
Ravikanth
>--Original Message--
>I have a page with a drop down and several web controls.
The drop down
>is set to postback and it reloads the textboxes based on
the selected
>drop down item. I set the focus to the first textbox
control on the
>client like this:
><script language="vbscript">
>Option Explicit
>...other code
>If Not <%=mbReadOnly%> Then
>document.frmDetails.txtName.focus()
>End If
>...other code
></script>
>This works fine on first page load but when I change the
drop down it
>does reset the focus and you can't even type in the
first textbox
>until you select another textbox first.
>To debug I added a message box right before the set
focus to see if it
>was even getting to this line of code and it works but I
can't leave a
>message box here.
>Any ideas on what could be the problem?
>Thanks in advance for any help,
>Deidre
>.
Thanks for the suggestion but it does the same thing if I put it in a
body onload event.
"Ravikanth[MVP]" <dvravikanth@.hotmail.com> wrote in message news:<0e1c01c34d31$17c134a0$a301280a@.phx.gbl>...
> Hi
> setfocus in body onload event,
> document.frmDetails.txtName.focus()
> HTH
> Ravikanth
I fixed my problem. I needed to move my set focus command to the window_onload sub:
Sub Window_OnLoad()
If Not <%=mbReadOnly%> Then
document.frmDetails.txtName.focus()
End If
End Sub
Deidre
0 comments:
Post a Comment