[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1126
  • Last Modified:

How to set focus to a textbox in a C# Wizard step inside an UpdatePanel

Tried many methods to place the cursor in a textbox in Wizard steps in a VS 2005 Wizard control. The control is inside an UpdatePanel. I can use a FindControl to identify the control successfully but the focus always defaults to the Step's Next button. My most recent code attempt is below. Suggestions?
//Called from an OnPreRender = "Wizard1_PreRender" statement in asp:Wizard
 
protected void Wizard1_PreRender(object sender, EventArgs e)
    {
        if (Wizard1.ActiveStep.Name == "Step 2")
        {
            TextBox textbox = (TextBox)Wizard1.FindControl("txtUserFirstName");
            Page.SetFocus(textbox);
        }
    }

Open in new window

0
Xignal76
Asked:
Xignal76
  • 2
2 Solutions
 
Bob LearnedCommented:
Did you try textbox.Focus()?
0
 
Xignal76Author Commented:
Had, but did it again just to be sure. Same result - the Next button got focus.
0
 
Xignal76Author Commented:
Figured out a workaround.

It works if you do not put the Wizard inside a single UpdatePanel, but instead place an UpdatePanel inside each WizardStep. The focus then gets set correctly.
0

Featured Post

[Webinar] Kill tickets & tabs using PowerShell

Are you tired of cycling through the same browser tabs everyday to close the same repetitive tickets? In this webinar JumpCloud will show how you can leverage RESTful APIs to build your own PowerShell modules to kill tickets & tabs using the PowerShell command Invoke-RestMethod.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now