Thank you for your response. I have made the adjustments to the code, but it still does not set focus on the login textbox when I run the application and click the TargetControl of the ModalPopupExtender.
Here is my code for the page...
[code behind]
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'====================== Java Code for ModalPopup TextBox focus ======================='
If Not Page.IsPostBack Then
If (Not Me.ClientScript.IsStartupScriptRegistered("Startup")) Then
Dim scriptString = "<script type='text/javascript'>" _
& "Sys.Application.add_load(modalSetup);" _
& "function SetFocusOnControl() {" _
& "$get('" _
& txtUsername.ClientID _
& "').focus(); }" _
& "function modalSetup() {" _
& "var modalPopup = $find('" _
& ModalPopupExtender1.ClientID _
& "');" _
& "modalPopup.add_shown(SetFocusOnControl); }" _
& "</script>"
Me.ClientScript.RegisterStartupScript(Me.GetType(), "Startup", scriptString)
End If
End If
'=================== End Java Code for ModalPopup TextBox Focus ====================='
End Sub
KJAK
Participant
1673 Points
478 Posts
Re: Set Focus on Textbox in modalPopup Panel
May 23, 2007 11:57 AM|LINK
Hi,
Thank you for your response. I have made the adjustments to the code, but it still does not set focus on the login textbox when I run the application and click the TargetControl of the ModalPopupExtender.
Here is my code for the page...
[code behind]
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load '====================== Java Code for ModalPopup TextBox focus =======================' If Not Page.IsPostBack Then If (Not Me.ClientScript.IsStartupScriptRegistered("Startup")) Then Dim scriptString = "<script type='text/javascript'>" _ & "Sys.Application.add_load(modalSetup);" _ & "function SetFocusOnControl() {" _ & "$get('" _ & txtUsername.ClientID _ & "').focus(); }" _ & "function modalSetup() {" _ & "var modalPopup = $find('" _ & ModalPopupExtender1.ClientID _ & "');" _ & "modalPopup.add_shown(SetFocusOnControl); }" _ & "</script>" Me.ClientScript.RegisterStartupScript(Me.GetType(), "Startup", scriptString) End If End If '=================== End Java Code for ModalPopup TextBox Focus =====================' End Sub[page code]
When debugging, the script appears to register. It just doesn't seem to be doing anything. Can you see any issues with my code?KJAK