control.focus() after selectedIndexChanged

Posted by kyle on Stack Overflow See other posts from Stack Overflow or by kyle
Published on 2011-03-07T16:08:54Z Indexed on 2011/03/07 16:10 UTC
Read the original article Hit count: 137

Filed under:
|
|

I need to focus on a textbox after an item has been selected from a dropdownlist.

I've tried control.focus() and setfocus().

The last thing I've tried was Set_Focus(dtbEffectiveDate.ClientID) inside the SelectedIndexChanged method with the folowing method.

Protected Sub Set_Focus(ByVal ControlName As String)
    Dim strScript As String

    strScript = "<script language=javascript> window.setTimeout(""" + ControlName + ".focus();"",0); </script>"
    RegisterStartupScript("focus", strScript)
End Sub

I'm out of answers so any help would be awesome.

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about .NET