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

Xignal76Asked:
Who is Participating?
 
Xignal76Connect With a Mentor Author 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
 
Bob LearnedConnect With a Mentor Commented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.