Hi Gary,
As for the Wizard control, those different Container (such as Navigation
Panel , SideBar Panel...) , they're separate from each other (under the
Wizard control's Sub control colleciton). Therefore, if you want to lookup
any child control within any of them, you need to get reference to the
certain container first. Generally, a useful means to determine the
control structure/hierarchy is turn on page's output trace (see the
below
directive):
=====================
<%@ Page Language="C#" AutoEventWireup="true"
CodeFile="CSWizard.aspx.cs"
Inherits="CSWizard"
Trace="true" %>
==================
And based on my test, the "Navigation container"'s control ID is
"StepNavigationTemplateContainerID". You can use it to get the Navigation
container control first, and call FindControl on it to get the
"MovePreviousButton" and "MoveNextButton".
here is a simple test page I've used. Also, "ActiveStepChanged" event
is
not the proper event to lookup control collection (because at that time,
the new Step's control collection hasn't been populatd yet). I suggest you
use "Load" event.
=============aspx template ======
<asp:Wizard ID="Wizard1" runat="server" ActiveStepIndex="1"
onactivestepchanged="Wizard1_ActiveStepChanged"
onload="Wizard1_Load">
<WizardSteps>
<asp:WizardStep runat="server" title="Step 1">
<asp:Label ID="Label1" runat="server"
Text="Label1"></asp:Label>
<br />
<asp:Button ID="Button1" runat="server"
Text="Button1"
/>
</asp:WizardStep>
<asp:WizardStep runat="server" title="Step 2">
<asp:Label ID="Label2" runat="server"
Text="Label2"></asp:Label>
<br />
<asp:Button ID="Button2" runat="server"
Text="Button2"
/>
</asp:WizardStep>
<asp:WizardStep runat="server" Title="Step 3">
<asp:Label ID="Label3" runat="server"
Text="Label3"></asp:Label>
<br />
<asp:Button ID="Button3" runat="server"
Text="Button3"
/>
</asp:WizardStep>
<asp:WizardStep runat="server" Title="Step 4">
<asp:Label ID="Label4" runat="server"
Text="Label4"></asp:Label>
<br />
<asp:Button ID="Button4" runat="server"
Text="Button4"
/>
</asp:WizardStep>
</WizardSteps>
<StepNavigationTemplate >
<asp:Button ID="StepPreviousButton" runat="server"
CausesValidation="False"
CommandName="MovePrevious" Text="Previous" />
<asp:Button ID="StepNextButton" runat="server"
CommandName="MoveNext"
Text="Next" />
</StepNavigationTemplate>
</asp:Wizard>
==========code behind=========
protected void Wizard1_Load(object sender, EventArgs e)
{
Control ctrl =
Wizard1.FindControl("StepNavigationTemplateContainerID");
Response.Write("<br/>Wizard1_Load:");
Button btn1 = ctrl.FindControl("StepPreviousButton") as Button;
Button btn2 = ctrl.FindControl("StepNextButton") as Button;
Response.Write("<br/>" + btn1 + " | " + btn2);
}
}
======================
Hope this helps.
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments
and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(e-mail address removed).
==================================================
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.
--------------------
From: "GaryDean" <
[email protected]>
Subject: Accessing Wizard Next/Prev buttons
Date: Thu, 26 Jun 2008 10:59:43 -0600
I have a Wizard page and need to affect the next and previous buttons from
my code-behind. I've googled around and found two solutions, and
neither
appear to work.
I can access the SideBarList steps successfully with the following code...
Control myContainer =
(Control)Wizard1.FindControl("SideBarContainer");
DataList mySideBarList =
(DataList)myContainer.FindControl("SideBarList");
mySideBarList.Enabled = false;
Trying to take this approach with the StepNavigationTemplate does not seem
to work. I first converted the step navigation to a template but I cannot
get findcontrol to find anything in "StepNavigationContainer" or
"StepNavigationTemplate" or anything else I can think of.
I have also tried putting .hidden {display:none} in my .css file and
....
protected void Wizard1_ActiveStepChanged(object sender, EventArgs e)
{
if (Wizard1.ActiveStepIndex == 3)
{
Wizard1.StepPreviousButtonStyle.CssClass = "hidden";
Wizard1.StepNextButtonStyle.CssClass = "hidden";
}
}
This has the effect of not working when goint to step 3 as the Prev/finish
still show. However if the prev button is hit, step 2 shows with the next
button not visible.
Is there a solution to this problem? Is there a reliable way to access
these buttons?
Thanks,
Gary