Showing posts with label drop. Show all posts
Showing posts with label drop. Show all posts

Saturday, March 24, 2012

Set focus problem

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

Thursday, March 22, 2012

set index of drop downbox

Hi,

I would like to set the selected item of drop downbox to the index of an
item that will only be known at run time.

I realise that if I were to know it at design time I could write

ddlResidentialCity.SelectedIndex = 3

however what I wish to do is say

ddlResidentialCity.SelectedIndex = Set to value of item who's text value is
"martin"

what I am unsure about is how to get the index of the item I wish to use as
the selected index

any help would be appreciated.

cheers

martinH

ddlResidentalCity.Items.FindByValue("martin").Selected = True
How about this?

ddlResidentialCity.SelectedValue = "martin"

"martin" <Stuart_REMOVE_36@.yahoo.com> wrote in message news:<#N9fYmwQEHA.132@.TK2MSFTNGP09.phx.gbl>...
> Hi,
> I would like to set the selected item of drop downbox to the index of an
> item that will only be known at run time.
> I realise that if I were to know it at design time I could write
> ddlResidentialCity.SelectedIndex = 3
> however what I wish to do is say
> ddlResidentialCity.SelectedIndex = Set to value of item who's text value is
> "martin"
> what I am unsure about is how to get the index of the item I wish to use as
> the selected index
>
> any help would be appreciated.
> cheers
> martin

set index of drop downbox

Hi,
I would like to set the selected item of drop downbox to the index of an
item that will only be known at run time.
I realise that if I were to know it at design time I could write
ddlResidentialCity.SelectedIndex = 3
however what I wish to do is say
ddlResidentialCity.SelectedIndex = Set to value of item who's text value is
"martin"
what I am unsure about is how to get the index of the item I wish to use as
the selected index
any help would be appreciated.
cheers
martinHi
ddlResidentalCity.Items.FindByValue("martin").Selected = True
ddlResidentialCity.SelectedIndex = ddlResidentalCity.Items.IndexOf( ddlResid
entalCity.Items.FindByText("martin"))
How about this?
ddlResidentialCity.SelectedValue = "martin"
"martin" <Stuart_REMOVE_36@.yahoo.com> wrote in message news:<#N9fYmwQEHA.132@.TK2MSFTNGP09.p
hx.gbl>...
> Hi,
> I would like to set the selected item of drop downbox to the index of an
> item that will only be known at run time.
> I realise that if I were to know it at design time I could write
> ddlResidentialCity.SelectedIndex = 3
> however what I wish to do is say
> ddlResidentialCity.SelectedIndex = Set to value of item who's text value i
s
> "martin"
> what I am unsure about is how to get the index of the item I wish to use a
s
> the selected index
>
> any help would be appreciated.
> cheers
> martin