On a recent project I needed to integrate the ASP:Wizard control with SharePoint 2010. The control hierarchy is:
SharePoint 2010 - > Visual Web Part -> Custom User Control -> ASP:Wizard Control
In this case, I wanted to simply use the Wizard control for state management, and suppress most of its UI and behavior. Navigation between the various Wizard step was accomplished by passing a query string on the URL called from the SharePoint Quick Launch into the Web Part, and then setting the Wizard active step in Page_Load:
if (Request.QueryString["ws"] != null)
int wizPage = Convert.ToInt32(Request.QueryString["ws"]);
Wizard1.ActiveStepIndex = wizPage;
The Wizard Side Bar normally handles direct navigation between steps, however in this case because I replaced it with the SharePoint Quick Launch, I hid the Side Bar by adding DisplaySideBar="False" to the Wizard tag in the user control ascx file. This freed some client space and provided effective use of the Quick Launch control.
Because my work flow was non-linear, I also wanted to hide the previous, next, and finish buttons normally displayed on the Wizard steps. This was accomplished by using the Wizard tasks context menu on the Visual Studio 2010 design surface for the user control aspx page to apply the StartNavigationTemplate, StepNavigationTemplate, and FinishNavigationTemplate. After generating this markup, I added Visible="false" Enabled="false" to each of the three buttons to make them go away.
The final step of the wizard integration was to dynamically set the Title of the Web Part based on the name of the Wizard step in the Wizard Step tags. However, the server side code for the Web Part class generated by the Visual Studio project wizard adds a generic Control instance to the Controls collection.
To allow access to the parent Visual Web Part from the user control containing the Wizard, the default code:
Control control = Page.LoadControl(_ascxPath);
Was replaced with:
VisualWebPart1UserControl control =
control.ParentWebPart = this;
This allowed assignment of the Wizard step name to the Title property of the Web Part so:
The ASP:Wizard control can be seamlessly integrated with a containing Visual Web Part and SharePoint 2010. In a future blog, I’ll describe contextual customization of the SharePoint 2010 ribbon control, for execution of custom user actions within each wizard step.