generate wizard steps automatically
-
Hi, how we can generate wizard steps automatically base on variable for example when page load check the value of the variable and then crate wizard steps equal to the value of variable and then set the property of each step. Thanks a ot :doh: :wtf: :confused:
-
Hi, how we can generate wizard steps automatically base on variable for example when page load check the value of the variable and then crate wizard steps equal to the value of variable and then set the property of each step. Thanks a ot :doh: :wtf: :confused:
Here is a simple example of programmatically creating wizard steps. The trick is to create the steps in the
PreInit
event of the page.<%@ Page Language="C#" %>
<script runat="server">
void Page_PreInit(object o, EventArgs e)
{
// simple data for constructing this wizard
string[] data = new string[3] {"What is your name? "
,"What is your quest? "
,"What is your favorite color? "
};for (int i=0; i<data.Length; i++) { WizardStep theStep = new WizardStep(); theStep.ID = "Step" + i.ToString(); theStep.Title = "Step " + i.ToString(); theStep.StepType = WizardStepType.Auto; // add some controls to the first step Label label1 = new Label(); label1.Text = "<br />" + data\[i\] + "<br />"; theStep.Controls.Add(label1); TextBox tb1 = new TextBox(); tb1.ID = "txt" + i.ToString(); theStep.Controls.Add(tb1); // add the step to the wizard wiz1.WizardSteps.Add(theStep); } // set the active step to the first wiz1.ActiveStepIndex=0;
}
</script>
<html>
<head></head>
<body>
<form runat="server">
<h3>Programmatically Adding Steps to Wizard</h3>
<hr />
<asp:Wizard id="wiz1" runat="server"
DisplaySideBar="true"
HeaderText="Wiz1"
BorderWidth="1" BorderColor="#CCCCCC" BorderStyle="Solid"
StepNextButtonText=" Next >> "
StepPreviousButtonText=" << Previous "
FinishCompleteButtonText=" Done! "
CellPadding="4"
>
<HeaderStyle BackColor="#999999"
ForeColor="#FFFFFF"
HorizontalAlign="center"
Font-Size="12" Font-Bold="True"
/>
<SideBarStyle BackColor="#EFEFEF"
/></asp:Wizard> <hr /> </form>
</body>
</html>