Customize the wizard layout template programmatically

I am creating a wizard control from code based on some conditions from a database. I need to apply a layout template from code. I checked the MS example, all this is based on development time, not runtime.

Please help me in customizing the layout template for managing the asp.net wizard. Some code examples are preferred.

Update:

I think I should have been a little more complicated. In fact, I do not see the controls in the wizard that I added from the template. Here is my sample code

public class WizardTemplate:ITemplate
{
    public void InstantiateIn(Control container)
    {
        PlaceHolder header = new PlaceHolder();
        header.Controls.Add(new LiteralControl("I am from Header"));
        header.ID = Wizard.HeaderPlaceholderId;

        PlaceHolder displaySideBar = new PlaceHolder();
        displaySideBar.Controls.Add(new LiteralControl("I am from displaySideBar"));
        displaySideBar.ID = Wizard.SideBarPlaceholderId;

        PlaceHolder wizardStep = new PlaceHolder();
        wizardStep.Controls.Add(new LiteralControl("I am from wizard step"));
        wizardStep.ID = Wizard.WizardStepPlaceholderId;

        PlaceHolder navigation = new PlaceHolder();
        navigation.ID = Wizard.NavigationPlaceholderId;

        container.Controls.Add(header);
        container.Controls.Add(displaySideBar);
        container.Controls.Add(wizardStep);

        container.Controls.Add(navigation);
    }
}

I do this on the init page. I do not see the controls that I created in it. I wonder what is going on here.

Wizard testWizard = new Wizard();
        testWizard.LayoutTemplate = new WizardTemplate();
        for (int i = 0; i < 4; i++)
        {
            WizardStep step = new WizardStep();
            step.Title = "Step" + i.ToString();
            step.ID = "Step" + i.ToString();
            step.Controls.Add(new LiteralControl("<b> Step" + i.ToString() + "</b>"));
            testWizard.WizardSteps.Add(step);

        }
        pnlRunTimeWizardContainer.Controls.Add(testWizard);

In the end, I would like the wizard to use the layout below, but in the code

<asp:Wizard ID="Wizard1" runat="server" EnableViewState="true">
        <LayoutTemplate>
            <div>
                <asp:PlaceHolder ID="headerPlaceHolder" runat="server" />
            </div>
            <div style="float: right">
                <asp:PlaceHolder ID="navigationPlaceHolder" runat="server" />
            </div>
            <div>
                <asp:PlaceHolder ID="sideBarPlaceHolder" runat="server" />
            </div>
            <div>
                <asp:PlaceHolder ID="WizardStepPlaceHolder" runat="server" />
            </div>
        </LayoutTemplate>
        <WizardSteps>
        </WizardSteps>
    </asp:Wizard>
+3
source share
1

:

public class WizardLayoutTemplate : ITemplate
{
  public void InstantiateIn(Control container)
  {
    // do some cool stuff here with the container control
  }
}

myWizard.LayoutTemplate = new WizardLayoutTemplate();
+2

All Articles