Showing posts with label wizard. Show all posts
Showing posts with label wizard. Show all posts

Saturday, 7 June 2008

ASP.NET Wizard - How do I modify templated buttons at runtime?

Accessing a Wizard's templated buttons at runtime is quite tricky and not very elegant using this approach - any better ideas/solutions are more than welcome!

<asp:Wizard ID="MyWizard" runat="server">
<StartNavigationTemplate>
<asp:Button ID="btnNext" runat="server" CommandName="MoveNext" Text="Next" />
</StartNavigationTemplate>
</asp:Wizard>

Control startNavigationTemplate = MyWizard.FindControl( "StartNavigationTemplateContainerID" ) as Control;

if ( startNavigationTemplate != null )
{
Button nextButton = startNavigationTemplate.FindControl( "btnNext" ) as Button ;

if ( nextButton != null )
{
// Do something.
}
}

To manipulate buttons in the step and finish navigiation templates, use StepNavigationTemplateContainerID and FinishNavigationTemplateContainerID respectively.

ASP.NET Wizard - Finish button CommandName

If you want to override the FinishNavigationTemplate template, the CommandName for the finish button is MoveComplete. I found several websites claiming it is MoveFinish but this won't trigger the event (definitely under the .NET 2.0 framework).

Example:

<asp:Wizard runat="server">
<FinishNavigationTemplate>
<asp:Button runat="server" CommandName="MoveComplete" Text="Finish" />
</FinishNavigationTemplate>
</asp:Wizard>