Defauly focus in a WizardStep

S

Steven Cheng[MSFT]

Hello Dave,

As for the focus in web page, the whole page wil only have a single focus.
So if you put wizard control on the page, those child controls in
wizardsteps also share this page focus. If you want to make a certain sub
control in your wizard control(in a certain wizardstep) get focus. You can
consider use Wizard control's Prerender event to get the control's
reference and then call Page.SetFocus against it. e.g.


==========aspx template==============
<asp:Wizard ID="Wizard1" runat="server" ActiveStepIndex="0" Height="135px"
Width="602px" OnPreRender="Wizard1_PreRender1">
<WizardSteps>
<asp:WizardStep runat="server" Title="Step 1">
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
</asp:WizardStep>
<asp:WizardStep runat="server" Title="Step 2"
OnPreRender="Wizard1_PreRender">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Button" />
<asp:LinkButton ID="LinkButton1"
runat="server">LinkButton</asp:LinkButton>
<asp:ImageButton ID="ImageButton1" runat="server" />
<asp:DropDownList ID="DropDownList1" runat="server">
<asp:ListItem>aaa</asp:ListItem>
<asp:ListItem>bbb</asp:ListItem>
<asp:ListItem>ccc</asp:ListItem>
</asp:DropDownList>
</asp:WizardStep>
<asp:WizardStep runat="server" StepType="Finish"
Title="Step 3">
<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox>
</asp:WizardStep>
</WizardSteps>
</asp:Wizard>

============code behind==========

protected void Wizard1_PreRender1(object sender, EventArgs e)
{
if (Wizard1.ActiveStepIndex == 1)
{
Control control =
Wizard1.WizardSteps[1].FindControl("DropDownList1");

Page.SetFocus(control);
}
}

==================

Hope this helps.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead



==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.



Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.

==================================================



This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top