Home All Groups Group Topic Archive Search About
Author
27 Feb 2007 7:37 PM
David Thielen
Hi;

How can I set the control to get the focus in a WizardStep? Everything I can
find shows how to do this for a form but in a wizard each step has a
different default control.

--
thanks - dave
david_at_windward_dot_net
http://www.windwardreports.com

Cubicle Wars - http://www.windwardreports.com/film.htm

Author
28 Feb 2007 6:57 AM
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.