Sample Code: Quick Intro to <asp:wizard> control in Whidbey
The <asp:wizard> control enables us to divide a
large form into multiple sub forms.
This is otherwise
traditionally done with ASP.NET v1.1 controls using
<asp:panel> or <asp:placeholder> on
one/multiple pages.
Handling Next/Previous/Finish can be done by setting the properties of the control
Some tags associated with the <asp:wizard> are
<wizardsteps>
<asp:wizardsteps>
<stepnavigationtemplate>
Here is just a sample of how to use the
<asp:wizard> control
<asp:wizard id="Wizard1" runat="server" onfinishbuttonclick="FinishbtnClick"
nextstepbuttontext="Next" finishstepbuttontext="Finish"
previousstepbuttontext="Previous" sidebarenabled="false"> <wizardsteps> <asp:wizardstep runat="server" steptype="start" title="Name/Password" id="Start"> Name: <asp:textbox id="txtName" runat="Server"></asp:textbox> <asp:requiredfieldvalidator runat="server" controltovalidate="txtName"
id="RequiredFieldValidator1" errormessage="*">
</asp:requiredfieldvalidator> <br /> Email:<asp:textbox id="txtEmail" runat="server"></asp:textbox> <asp:regularexpressionvalidator id="Regularexpressionvalidator1" runat="server"
errormessage="Invalid Email" controltovalidate="txtEmail"
validationexpression="\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*"> </asp:regularexpressionvalidator> </asp:wizardstep> <asp:wizardstep id="step" steptype="step" runat="server" title="Address/City"> Address:<asp:textbox id="txtAddress" textmode="multiline" runat="server">
</asp:textbox> <br /> City:<asp:textbox id="txtCity" runat="server"></asp:textbox> </asp:wizardstep> <asp:wizardstep id="Finish" steptype="finish" runat="server" title="Finish"> Description:<asp:textbox id="txtDescription" runat="server">
</asp:textbox> <br /> Comments:<asp:textbox id="txtComments" runat="server" textmode="multiLine">
</asp:textbox> </asp:wizardstep> <asp:wizardstep id="Complete" steptype="complete" runat="server" title="Data Entered"> <asp:bulletedlist id="Bulletedlist1" runat="server"> </asp:bulletedlist> </asp:wizardstep> </wizardsteps> </asp:wizard>
<script runat="server" language="vb"> Sub FinishbtnClick(ByVal sender As Object, _
ByVal e As System.Web.UI.WebControls.WizardNavigationEventArgs) Bulletedlist1.Items.Add("Name : " & txtName.Text) Bulletedlist1.Items.Add("Email : " & txtEmail.Text) Bulletedlist1.Items.Add("Address : " & txtAddress.Text) Bulletedlist1.Items.Add("City : " & txtCity.Text) Bulletedlist1.Items.Add("Description : " & txtDescription.Text) Bulletedlist1.Items.Add("Comments : " & txtComments.Text) End Sub </script>
|
<asp:wizard> Attribute/Settings |
Description |
|
nextstepbuttontext,previoustepbuttontext, finishstepbuttontext |
Text for the Next/Previous/Finish button |
|
sidebarenabled |
Boolean value set to true/false to display/hide the title set for sidebar |
|
<asp:wizardstep> Attribute/Settings |
Description |
|
Steptype |
In the order of appearance:Start,Step,Finish,Complete |
|
title |
If the sidebarenabled is true then the text given in title appears in sidebar. |