troubleshooting Question

Default control focus in ASP.NET 2.0 Wizard on page using Master template

Avatar of DanielBorson
DanielBorsonFlag for United States of America asked on
4 Comments1 Solution1046 ViewsLast Modified:
In ASP.NET 2.0, I have a Wizard control that is inside of an <asp:Content> tag. The <form> tag is in a Master template file. My question is how can I set a textbox to have default focus? When I try to do it from the code-behind by using "textbox.Focus()" I get an error that there is no Form, and therefore the focus cannot be set. On other pages that also use the Master template, I employ client-side JavaScript to set focus, but since this is a Wizard control, there would be several controls that would need default focus at different steps in the Wizard.

I've thought of a workaround by having a hidden textobx with the Wizard ActiveStepIndex and a switch/case in the client-side JavaScript that would set the focus to different controls, based on the ActiveStepIndex, but that seems like a bigger workaround than should be necessary. Is there another (and simpler) way to do this?


Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 4 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros