Thank you! I had to modify it slightly do to my application being written in VB.NET, but I have gotten it working now!
Here is the code that finally worked:
[codebehind]
If Not Page.IsPostBack Then
If (Not Me.ClientScript.IsStartupScriptRegistered("Startup")) Then
Dim sb As StringBuilder = New StringBuilder()
sb.Append("<script type=""text/javascript\"">")
sb.Append("Sys.Application.add_load(modalSetup);")
sb.Append("function modalSetup() {")
sb.Append(String.Format("var modalPopup = $find('{0}');", ModalPopupExtender1.BehaviorID))
sb.Append("modalPopup.add_shown(SetFocusOnControl); }")
sb.Append("function SetFocusOnControl() {")
sb.Append(String.Format("var textBox1 = $get('{0}');", txtUsername.ClientID))
sb.Append("textBox1.focus();}")
sb.Append("</script>")
Page.ClientScript.RegisterStartupScript(Page.GetType(), "Startup", sb.ToString())
End If
End If
Thank you all for your assistance with this issue. Hopefully this thread will be useful to others in the future!
KJAK
Participant
1673 Points
478 Posts
Re: Set Focus on Textbox in modalPopup Panel
May 23, 2007 04:05 PM|LINK
YES!
Thank you! I had to modify it slightly do to my application being written in VB.NET, but I have gotten it working now!
Here is the code that finally worked:
[codebehind]
If Not Page.IsPostBack Then If (Not Me.ClientScript.IsStartupScriptRegistered("Startup")) Then Dim sb As StringBuilder = New StringBuilder() sb.Append("<script type=""text/javascript\"">") sb.Append("Sys.Application.add_load(modalSetup);") sb.Append("function modalSetup() {") sb.Append(String.Format("var modalPopup = $find('{0}');", ModalPopupExtender1.BehaviorID)) sb.Append("modalPopup.add_shown(SetFocusOnControl); }") sb.Append("function SetFocusOnControl() {") sb.Append(String.Format("var textBox1 = $get('{0}');", txtUsername.ClientID)) sb.Append("textBox1.focus();}") sb.Append("</script>") Page.ClientScript.RegisterStartupScript(Page.GetType(), "Startup", sb.ToString()) End If End IfThank you all for your assistance with this issue. Hopefully this thread will be useful to others in the future!Sincerely,
KJAK
KJAK