1、缺点:我一下子点最后的step,也有结果,这样不好!(应该在第一步时第二、三都处于非激活状态,像安装vsdotnet时看到的效果)。只要属性、方法:
方法:OnFinishButtonClick、OnActiveStepChanged
属性:AllowReturn
2、由于上面那个问题我还没解决,所以现在对它还不感兴趣。下面提供网络上的三例子体现它的基本功能。
(1)
<%
...
@ Page Language="C#"
%>
<! DOCTYPE html PUBLIC "-//W3C//DTD XHTML
1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >
< script runat ="server" > ... public int score=0;
void scorefunction(Object sender, WizardNavigationEventArgs
e)
...{
if (RBL1.SelectedValue == "a")
...{
score += 1;
}
if (RBL2.SelectedValue == "c")
...{
score += 1;
}
if (RBL3.SelectedValue == "c")
...{
score += 1;
}
msg.Text = score.ToString();
}</script>
<html
xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Linear Wizard</title>
</head>
<body >
<form id="form1"
runat="server">
<div align=center>
<asp:Wizard ID="Wizard1"
runat="server" BackColor="#FFFBD6"
BorderColor="#FFDFAD" onfinishbuttonclick="scorefunction"
Height="160px" Width="480px" ActiveStepIndex="0"
BorderWidth="0px" Font-Names="Verdana"
Font-Size="0.8em" HeaderText="Linear Wizard Example" SideBarStyle-BorderWidth="0"
DisplaySideBar="true" SideBarStyle-BorderStyle="None"
SideBarButtonStyle-Font-Size="Small"
SideBarButtonStyle-Font-Bold="true"
SideBarStyle-BackColor="AliceBlue"
SideBarStyle-BorderColor="Red">
<WizardSteps>
<asp:WizardStep runat="server"
id=step1 StepType="Start">
1.When did India got independence?
<asp:RadioButtonList ID="RBL1"
runat="server">
<asp:ListItem
Value="a">1947</asp:ListItem>
<asp:ListItem
Value="b">1847</asp:ListItem>
<asp:ListItem
Value="c">1957</asp:ListItem>
<asp:ListItem
Value="d">1937</asp:ListItem>
</asp:RadioButtonList>
</asp:WizardStep>
<asp:WizardStep id=step2
runat="server">
2.When did USA got independence?
<asp:RadioButtonList ID="RBL2"
runat="server" >
<asp:ListItem
Value="a">1666</asp:ListItem>
<asp:ListItem
Value="b">1886</asp:ListItem>
<asp:ListItem
Value="c">1776</asp:ListItem>
<asp:ListItem
Value="d">1786</asp:ListItem>
</asp:RadioButtonList>
</asp:WizardStep>
<asp:WizardStep runat="server"
id=step3 StepType="Finish">
<asp:Label runat="server"
width="408px" height="24px">This is Last
Question</asp:Label>
3.Which of the following countries joined UN
recently?
<asp:RadioButtonList ID="RBL3"
runat="server" >
<asp:ListItem Value="a">Luxembourg</asp:ListItem>
<asp:ListItem Value="b">Germany</asp:ListItem>
<asp:ListItem
Value="c">Swirtzerland</asp:ListItem>
<asp:ListItem Value="d">Poland</asp:ListItem>
</asp:RadioButtonList>
</asp:WizardStep>
<asp:WizardStep runat="server"
id=step4 StepType="Complete">
<center>Your score is : <asp:label
ID=msg runat=server/></center>
</asp:WizardStep>
</WizardSteps>
<NavigationButtonStyle
BackColor="White" BorderStyle="Solid"
BorderColor="#CC9966" BorderWidth="1px"
Font-Names="Verdana" Font-Size="0.8em"
ForeColor="#990000" />
<HeaderStyle BackColor="#FFCC66" BorderColor="#FFFBD6"
BorderStyle="Solid" HorizontalAlign="Center"
BorderWidth="0px" Font-Bold="True"
Font-Size="0.9em" ForeColor="#333333"
Width="480px" />
<SideBarStyle BackColor="blue"
Font-Size="8pt" Width="0px" BorderStyle="None"
BorderWidth="0px" Wrap="True" />
<SideBarButtonStyle ForeColor="White"
/>
</asp:Wizard>
</div>
</form>
</body>
</html>
<! DOCTYPE html PUBLIC "-//W3C//DTD XHTML
1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >
< script runat ="server" > ... public int score=0;
void scorefunction(Object sender, WizardNavigationEventArgs
e)
...{
if (RBL1.SelectedValue == "a")
...{
score += 1;
}
if (RBL2.SelectedValue == "c")
...{
score += 1;
}
if (RBL3.SelectedValue == "c")
...{
score += 1;
}
msg.Text = score.ToString();
}</script>
<html
xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Linear Wizard</title>
</head>
<body >
<form id="form1"
runat="server">
<div align=center>
<asp:Wizard ID="Wizard1"
runat="server" BackColor="#FFFBD6"
BorderColor="#FFDFAD" onfinishbuttonclick="scorefunction"
Height="160px" Width="480px" ActiveStepIndex="0"
BorderWidth="0px" Font-Names="Verdana"
Font-Size="0.8em" HeaderText="Linear Wizard Example" SideBarStyle-BorderWidth="0"
DisplaySideBar="true" SideBarStyle-BorderStyle="None"
SideBarButtonStyle-Font-Size="Small"
SideBarButtonStyle-Font-Bold="true"
SideBarStyle-BackColor="AliceBlue"
SideBarStyle-BorderColor="Red">
<WizardSteps>
<asp:WizardStep runat="server"
id=step1 StepType="Start">
1.When did India got independence?
<asp:RadioButtonList ID="RBL1"
runat="server">
<asp:ListItem
Value="a">1947</asp:ListItem>
<asp:ListItem
Value="b">1847</asp:ListItem>
<asp:ListItem
Value="c">1957</asp:ListItem>
<asp:ListItem
Value="d">1937</asp:ListItem>
</asp:RadioButtonList>
</asp:WizardStep>
<asp:WizardStep id=step2
runat="server">
2.When did USA got independence?
<asp:RadioButtonList ID="RBL2"
runat="server" >
<asp:ListItem
Value="a">1666</asp:ListItem>
<asp:ListItem
Value="b">1886</asp:ListItem>
<asp:ListItem
Value="c">1776</asp:ListItem>
<asp:ListItem
Value="d">1786</asp:ListItem>
</asp:RadioButtonList>
</asp:WizardStep>
<asp:WizardStep runat="server"
id=step3 StepType="Finish">
<asp:Label runat="server"
width="408px" height="24px">This is Last
Question</asp:Label>
3.Which of the following countries joined UN
recently?
<asp:RadioButtonList ID="RBL3"
runat="server" >
<asp:ListItem Value="a">Luxembourg</asp:ListItem>
<asp:ListItem Value="b">Germany</asp:ListItem>
<asp:ListItem
Value="c">Swirtzerland</asp:ListItem>
<asp:ListItem Value="d">Poland</asp:ListItem>
</asp:RadioButtonList>
</asp:WizardStep>
<asp:WizardStep runat="server"
id=step4 StepType="Complete">
<center>Your score is : <asp:label
ID=msg runat=server/></center>
</asp:WizardStep>
</WizardSteps>
<NavigationButtonStyle
BackColor="White" BorderStyle="Solid"
BorderColor="#CC9966" BorderWidth="1px"
Font-Names="Verdana" Font-Size="0.8em"
ForeColor="#990000" />
<HeaderStyle BackColor="#FFCC66" BorderColor="#FFFBD6"
BorderStyle="Solid" HorizontalAlign="Center"
BorderWidth="0px" Font-Bold="True"
Font-Size="0.9em" ForeColor="#333333"
Width="480px" />
<SideBarStyle BackColor="blue"
Font-Size="8pt" Width="0px" BorderStyle="None"
BorderWidth="0px" Wrap="True" />
<SideBarButtonStyle ForeColor="White"
/>
</asp:Wizard>
</div>
</form>
</body>
</html>
(2)这个不是1~last那样直线下去,如果第一步大于5,就直接跳到第三步。
<%
...
@ Page Language="C#"
%>
<! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd" >
< script language ="C#" runat ="server" > ...
void SkipStep(object sender, WizardNavigationEventArgs e)
...{
if (e.CurrentStepIndex == 0 && Int32.Parse(DropDownList1.SelectedItem.Value) > 5)
Wizard1.ActiveStepIndex = 2;
}
void GetFavoriteNumerOnActiveStepIndex(Object Sender, EventArgs e)
...{
if (Wizard1.ActiveStepIndex >= 1)
Label1.Text = "The value selected on Step 1 is: " + DropDownList1.SelectedItem.Text;
if (Wizard1.ActiveStepIndex >= 2)
Label2.Text = "The value selected on Step 2 is: " + DropDownList2.SelectedItem.Text;
if (Wizard1.ActiveStepIndex >= 3)
Label3.Text = "The value selected on Step 3 is: " + DropDownList3.SelectedItem.Text;
}
</ script >
< html xmlns ="http://www.w3.org/1999/xhtml" >
< head runat ="server" >
< title > Wizard NonLinear Navigation </ title >
</ head >
< body >
< form id ="form1" runat ="server" >
< h2 >
Wizard Non-Linear Navigation Sample </ h2 >
< div >
In this sample, if the number that you select on the first step is greater then
5 you will skip WizardStep 2 and go directly to WizardStep 3. Try selecting different
numbers on the WizardStep 1 to see the different behaviors. < br />
< br />
Note: That when if you skip WizardStep 2 and click the previous button on WizardStep
3 you will be returned to WizardStep 1 the previous step that you visited. < br />
< br />
< br />
< asp:Wizard ID ="Wizard1" runat ="server" ActiveStepIndex ="0" Width ="322px" OnNextButtonClick ="SkipStep"
OnActiveStepChanged ="GetFavoriteNumerOnActiveStepIndex" BackColor ="#FFFBD6" BorderColor ="#FFDFAD"
BorderWidth ="1px" CellPadding ="5" Font-Names ="Verdana" Font-Size ="0.8em" DisplaySideBar ="False" >
< WizardSteps >
< asp:WizardStep runat ="server" Title ="Step 1" >
Wizard Step 1 < br />
< br />
Favorite Numer:
< asp:DropDownList ID ="DropDownList1" runat ="server" >
< asp:ListItem > 1 </ asp:ListItem >
< asp:ListItem > 2 </ asp:ListItem >
< asp:ListItem > 3 </ asp:ListItem >
< asp:ListItem > 4 </ asp:ListItem >
< asp:ListItem > 5 </ asp:ListItem >
< asp:ListItem > 6 </ asp:ListItem >
< asp:ListItem > 7 </ asp:ListItem >
< asp:ListItem > 8 </ asp:ListItem >
< asp:ListItem > 9 </ asp:ListItem >
< asp:ListItem > 10 </ asp:ListItem >
</ asp:DropDownList >
< br />
</ asp:WizardStep >
< asp:WizardStep runat ="server" Title ="Step 2" >
WizardStep 2 < br />
< br />
Favorite Color: < asp:DropDownList ID ="DropDownList2" runat ="server" >
< asp:ListItem > Red </ asp:ListItem >
< asp:ListItem > Blue </ asp:ListItem >
< asp:ListItem > Green </ asp:ListItem >
< asp:ListItem > Purple </ asp:ListItem >
< asp:ListItem > Black </ asp:ListItem >
< asp:ListItem > Brown </ asp:ListItem >
< asp:ListItem > Pink </ asp:ListItem >
< asp:ListItem > Orange </ asp:ListItem >
< asp:ListItem > Yellow </ asp:ListItem >
</ asp:DropDownList >
</ asp:WizardStep >
< asp:WizardStep ID ="Step3" runat ="server" Title ="Step 3" >
WizardStep 3 < br />
< br />
Favorite Sport:
< asp:DropDownList ID ="DropDownList3" runat ="server" >
< asp:ListItem > Soccer </ asp:ListItem >
< asp:ListItem > Baseball </ asp:ListItem >
< asp:ListItem > Football </ asp:ListItem >
< asp:ListItem > Hockey </ asp:ListItem >
< asp:ListItem > Basketball </ asp:ListItem >
< asp:ListItem > Tennis </ asp:ListItem >
< asp:ListItem > Rugby </ asp:ListItem >
< asp:ListItem > Cricket </ asp:ListItem >
</ asp:DropDownList >
</ asp:WizardStep >
< asp:WizardStep ID ="Complete" runat ="server" StepType ="Complete" Title ="Complete " >
< br />
Thank you for completing this survey. < br />
</ asp:WizardStep >
</ WizardSteps >
</ asp:Wizard >
< br />
< br />
< asp:Label ID ="Label1" runat ="server" ></ asp:Label >
< br />
< br />
< asp:Label ID ="Label2" runat ="server" ></ asp:Label >
< br />
< br />
< asp:Label ID ="Label3" runat ="server" ></ asp:Label >
< br />
</ div >
</ form >
</ body >
</ html >
<! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd" >
< script language ="C#" runat ="server" > ...
void SkipStep(object sender, WizardNavigationEventArgs e)
...{
if (e.CurrentStepIndex == 0 && Int32.Parse(DropDownList1.SelectedItem.Value) > 5)
Wizard1.ActiveStepIndex = 2;
}
void GetFavoriteNumerOnActiveStepIndex(Object Sender, EventArgs e)
...{
if (Wizard1.ActiveStepIndex >= 1)
Label1.Text = "The value selected on Step 1 is: " + DropDownList1.SelectedItem.Text;
if (Wizard1.ActiveStepIndex >= 2)
Label2.Text = "The value selected on Step 2 is: " + DropDownList2.SelectedItem.Text;
if (Wizard1.ActiveStepIndex >= 3)
Label3.Text = "The value selected on Step 3 is: " + DropDownList3.SelectedItem.Text;
}
</ script >
< html xmlns ="http://www.w3.org/1999/xhtml" >
< head runat ="server" >
< title > Wizard NonLinear Navigation </ title >
</ head >
< body >
< form id ="form1" runat ="server" >
< h2 >
Wizard Non-Linear Navigation Sample </ h2 >
< div >
In this sample, if the number that you select on the first step is greater then
5 you will skip WizardStep 2 and go directly to WizardStep 3. Try selecting different
numbers on the WizardStep 1 to see the different behaviors. < br />
< br />
Note: That when if you skip WizardStep 2 and click the previous button on WizardStep
3 you will be returned to WizardStep 1 the previous step that you visited. < br />
< br />
< br />
< asp:Wizard ID ="Wizard1" runat ="server" ActiveStepIndex ="0" Width ="322px" OnNextButtonClick ="SkipStep"
OnActiveStepChanged ="GetFavoriteNumerOnActiveStepIndex" BackColor ="#FFFBD6" BorderColor ="#FFDFAD"
BorderWidth ="1px" CellPadding ="5" Font-Names ="Verdana" Font-Size ="0.8em" DisplaySideBar ="False" >
< WizardSteps >
< asp:WizardStep runat ="server" Title ="Step 1" >
Wizard Step 1 < br />
< br />
Favorite Numer:
< asp:DropDownList ID ="DropDownList1" runat ="server" >
< asp:ListItem > 1 </ asp:ListItem >
< asp:ListItem > 2 </ asp:ListItem >
< asp:ListItem > 3 </ asp:ListItem >
< asp:ListItem > 4 </ asp:ListItem >
< asp:ListItem > 5 </ asp:ListItem >
< asp:ListItem > 6 </ asp:ListItem >
< asp:ListItem > 7 </ asp:ListItem >
< asp:ListItem > 8 </ asp:ListItem >
< asp:ListItem > 9 </ asp:ListItem >
< asp:ListItem > 10 </ asp:ListItem >
</ asp:DropDownList >
< br />
</ asp:WizardStep >
< asp:WizardStep runat ="server" Title ="Step 2" >
WizardStep 2 < br />
< br />
Favorite Color: < asp:DropDownList ID ="DropDownList2" runat ="server" >
< asp:ListItem > Red </ asp:ListItem >
< asp:ListItem > Blue </ asp:ListItem >
< asp:ListItem > Green </ asp:ListItem >
< asp:ListItem > Purple </ asp:ListItem >
< asp:ListItem > Black </ asp:ListItem >
< asp:ListItem > Brown </ asp:ListItem >
< asp:ListItem > Pink </ asp:ListItem >
< asp:ListItem > Orange </ asp:ListItem >
< asp:ListItem > Yellow </ asp:ListItem >
</ asp:DropDownList >
</ asp:WizardStep >
< asp:WizardStep ID ="Step3" runat ="server" Title ="Step 3" >
WizardStep 3 < br />
< br />
Favorite Sport:
< asp:DropDownList ID ="DropDownList3" runat ="server" >
< asp:ListItem > Soccer </ asp:ListItem >
< asp:ListItem > Baseball </ asp:ListItem >
< asp:ListItem > Football </ asp:ListItem >
< asp:ListItem > Hockey </ asp:ListItem >
< asp:ListItem > Basketball </ asp:ListItem >
< asp:ListItem > Tennis </ asp:ListItem >
< asp:ListItem > Rugby </ asp:ListItem >
< asp:ListItem > Cricket </ asp:ListItem >
</ asp:DropDownList >
</ asp:WizardStep >
< asp:WizardStep ID ="Complete" runat ="server" StepType ="Complete" Title ="Complete " >
< br />
Thank you for completing this survey. < br />
</ asp:WizardStep >
</ WizardSteps >
</ asp:Wizard >
< br />
< br />
< asp:Label ID ="Label1" runat ="server" ></ asp:Label >
< br />
< br />
< asp:Label ID ="Label2" runat ="server" ></ asp:Label >
< br />
< br />
< asp:Label ID ="Label3" runat ="server" ></ asp:Label >
< br />
</ div >
</ form >
</ body >
</ html >
(3)比较经典的学习例子
<%
...
@ Page Language="C#"
%>
<! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd" >
< script language ="C#" runat ="server" > ...
void GetFavoriteNumerOnActiveStepIndex(Object Sender, EventArgs e)
...{
if (Wizard1.ActiveStepIndex >= 1)
Label1.Text = "The value selected on Step 1 is: " + DropDownList1.SelectedItem.Text;
if (Wizard1.ActiveStepIndex >= 2)
Label2.Text = "The value selected on Step 2 is: " + DropDownList2.SelectedItem.Text;
if (Wizard1.ActiveStepIndex >= 3)
Label3.Text = "The value selected on Step 3 is: " + DropDownList3.SelectedItem.Text;
}
void GetAllValues(object sender, WizardNavigationEventArgs e)
...{
Label4.Text = "The value selected on Step 1 is: " + DropDownList4.SelectedItem.Text;
Label5.Text = "The value selected on Step 2 is: " + DropDownList5.SelectedItem.Text;
Label6.Text = "The value selected on Step 3 is: " + DropDownList6.SelectedItem.Text;
}
</ script >
< html xmlns ="http://www.w3.org/1999/xhtml" >
< head runat ="server" >
< title > Wizard Commit Model Samples </ title >
</ head >
< body >
< form id ="form1" runat ="server" >
< div >
< br />
< h2 >
Wizard Commitment Model Samples </ h2 >
< table id ="TABLE1" language ="javascript" >
< tr >
< td bgcolor ="#eff3fb" valign ="top" >
< b > Wizard Commit As You Go Sample </ b >< br />
Select items on each step and click the next button. Notice that your selection
is written out to a label each time you click a next button and that no previous
button is displayed because the AllowReturn=False is set for each step. </ td >
< td >
</ td >
< td bgcolor ="#fffbd6" valign ="top" >
< b > Wizard Commit At the End Sample </ b >< br />
Select an item on each step and click the next or finish button. Notice that all
of your selections are written out to labels after you click the finish button on
the final wizard step. You can also click the previous button and change your selection. </ td >
</ tr >
< tr >
< td bgcolor ="#eff3fb" >
< asp:Wizard ID ="Wizard1" runat ="server" ActiveStepIndex ="0" Width ="322px" OnActiveStepChanged ="GetFavoriteNumerOnActiveStepIndex"
BackColor ="#EFF3FB" BorderColor ="#B5C7DE" BorderWidth ="1px" Font-Names ="Verdana"
CellPadding ="5" >
< WizardSteps >
< asp:WizardStep runat ="server" Title ="Step 1" AllowReturn ="False" >
Wizard Step 1 < br />
< br />
Favorite Number:
< asp:DropDownList ID ="DropDownList1" runat ="server" >
< asp:ListItem > 1 </ asp:ListItem >
< asp:ListItem > 2 </ asp:ListItem >
< asp:ListItem > 3 </ asp:ListItem >
< asp:ListItem > 4 </ asp:ListItem >
< asp:ListItem > 5 </ asp:ListItem >
< asp:ListItem > 6 </ asp:ListItem >
< asp:ListItem > 7 </ asp:ListItem >
< asp:ListItem > 8 </ asp:ListItem >
< asp:ListItem > 9 </ asp:ListItem >
< asp:ListItem > 10 </ asp:ListItem >
</ asp:DropDownList >
< br />
</ asp:WizardStep >
< asp:WizardStep runat ="server" Title ="Step 2" AllowReturn ="False" >
Favorite Color: < asp:DropDownList ID ="DropDownList2" runat ="server" >
< asp:ListItem > Red </ asp:ListItem >
< asp:ListItem > Blue </ asp:ListItem >
< asp:ListItem > Green </ asp:ListItem >
< asp:ListItem > Purple </ asp:ListItem >
< asp:ListItem > Black </ asp:ListItem >
< asp:ListItem > Brown </ asp:ListItem >
< asp:ListItem > Pink </ asp:ListItem >
< asp:ListItem > Orange </ asp:ListItem >
< asp:ListItem > Yellow </ asp:ListItem >
</ asp:DropDownList >
</ asp:WizardStep >
< asp:WizardStep AllowReturn ="False" ID ="Step3" runat ="server" Title ="Step 3" StepType ="Step" >
Favorite Sport:
< asp:DropDownList ID ="DropDownList3" runat ="server" >
< asp:ListItem > Soccer </ asp:ListItem >
< asp:ListItem > Baseball </ asp:ListItem >
< asp:ListItem > Football </ asp:ListItem >
< asp:ListItem > Hockey </ asp:ListItem >
< asp:ListItem > Basketball </ asp:ListItem >
< asp:ListItem > Tennis </ asp:ListItem >
< asp:ListItem > Rugby </ asp:ListItem >
< asp:ListItem > Cricket </ asp:ListItem >
</ asp:DropDownList >
</ asp:WizardStep >
< asp:WizardStep ID ="Complete" runat ="server" Title ="Complete " StepType ="Complete" >
< br />
Thank you for completing this survey. < br />
</ asp:WizardStep >
</ WizardSteps >
< StepStyle Font-Size ="0.8em" ForeColor ="#333333" />
< SideBarStyle BackColor ="#507CD1" Font-Size ="0.9em" VerticalAlign ="Top" />
< NavigationButtonStyle BackColor ="White" BorderColor ="#507CD1" BorderStyle ="Solid"
BorderWidth ="1px" Font-Names ="Verdana" Font-Size ="0.8em" ForeColor ="#284E98" />
< SideBarButtonStyle BackColor ="#507CD1" Font-Names ="Verdana" ForeColor ="White" />
< HeaderStyle BackColor ="#284E98" BorderColor ="#EFF3FB" BorderStyle ="Solid" BorderWidth ="2px"
Font-Bold ="True" Font-Size ="0.9em" ForeColor ="White" HorizontalAlign ="Center" />
</ asp:Wizard >
</ td >
< td >
</ td >
< td bgcolor ="#fffbd6" >
< asp:Wizard ID ="Wizard2" runat ="server" ActiveStepIndex ="0" Width ="322px" OnFinishButtonClick ="GetAllValues"
BackColor ="#FFFBD6" BorderColor ="#FFDFAD" BorderWidth ="1px" Font-Names ="Verdana"
Font-Size ="0.8em" CellPadding ="5" >
< WizardSteps >
< asp:WizardStep runat ="server" Title ="Step 1" >
Wizard Step 1 < br />
< br />
Favorite Number:
< asp:DropDownList ID ="DropDownList4" runat ="server" >
< asp:ListItem > 1 </ asp:ListItem >
< asp:ListItem > 2 </ asp:ListItem >
< asp:ListItem > 3 </ asp:ListItem >
< asp:ListItem > 4 </ asp:ListItem >
< asp:ListItem > 5 </ asp:ListItem >
< asp:ListItem > 6 </ asp:ListItem >
< asp:ListItem > 7 </ asp:ListItem >
< asp:ListItem > 8 </ asp:ListItem >
< asp:ListItem > 9 </ asp:ListItem >
< asp:ListItem > 10 </ asp:ListItem >
</ asp:DropDownList >
< br />
</ asp:WizardStep >
< asp:WizardStep runat ="server" Title ="Step 2" >
Favorite Color: < asp:DropDownList ID ="DropDownList5" runat ="server" >
< asp:ListItem > Red </ asp:ListItem >
< asp:ListItem > Blue </ asp:ListItem >
< asp:ListItem > Green </ asp:ListItem >
< asp:ListItem > Purple </ asp:ListItem >
< asp:ListItem > Black </ asp:ListItem >
< asp:ListItem > Brown </ asp:ListItem >
< asp:ListItem > Pink </ asp:ListItem >
< asp:ListItem > Orange </ asp:ListItem >
< asp:ListItem > Yellow </ asp:ListItem >
</ asp:DropDownList >
</ asp:WizardStep >
< asp:WizardStep runat ="server" Title ="Step 3" >
Favorite Sport:
< asp:DropDownList ID ="DropDownList6" runat ="server" >
< asp:ListItem > Soccer </ asp:ListItem >
< asp:ListItem > Baseball </ asp:ListItem >
< asp:ListItem > Football </ asp:ListItem >
< asp:ListItem > Hockey </ asp:ListItem >
< asp:ListItem > Basketball </ asp:ListItem >
< asp:ListItem > Tennis </ asp:ListItem >
< asp:ListItem > Rugby </ asp:ListItem >
< asp:ListItem > Cricket </ asp:ListItem >
</ asp:DropDownList >
</ asp:WizardStep >
< asp:WizardStep runat ="server" StepType ="Complete" Title ="Complete " >
< br />
Thank you for completing this survey. < br />
</ asp:WizardStep >
</ WizardSteps >
< SideBarStyle BackColor ="#990000" Font-Size ="0.9em" VerticalAlign ="Top" />
< NavigationButtonStyle BackColor ="White" BorderColor ="#CC9966" BorderStyle ="Solid"
BorderWidth ="1px" Font-Names ="Verdana" Font-Size ="0.8em" ForeColor ="#990000" />
< SideBarButtonStyle ForeColor ="White" />
< HeaderStyle BackColor ="#FFCC66" BorderColor ="#FFFBD6" BorderStyle ="Solid" BorderWidth ="2px"
Font-Bold ="True" Font-Size ="0.9em" ForeColor ="#333333" HorizontalAlign ="Center" />
</ asp:Wizard >
</ td >
</ tr >
< tr >
< td bgcolor ="#eff3fb" >
< asp:Label ID ="Label1" runat ="server" ></ asp:Label >< br />
< br />
< asp:Label ID ="Label2" runat ="server" ></ asp:Label >< br />
< br />
< asp:Label ID ="Label3" runat ="server" ></ asp:Label ></ td >
< td >
</ td >
< td bgcolor ="#fffbd6" >
< asp:Label ID ="Label4" runat ="server" ></ asp:Label >< br />
< br />
< asp:Label ID ="Label5" runat ="server" ></ asp:Label >< br />
< br />
< asp:Label ID ="Label6" runat ="server" ></ asp:Label ></ td >
</ tr >
</ table >
< br />
< br />
< br />
< br />
< br />
< br />
< br />
< br />
< br />
< br />
< br />
< br />
< br />
< br />
</ div >
</ form >
</ body >
</ html >
<! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd" >
< script language ="C#" runat ="server" > ...
void GetFavoriteNumerOnActiveStepIndex(Object Sender, EventArgs e)
...{
if (Wizard1.ActiveStepIndex >= 1)
Label1.Text = "The value selected on Step 1 is: " + DropDownList1.SelectedItem.Text;
if (Wizard1.ActiveStepIndex >= 2)
Label2.Text = "The value selected on Step 2 is: " + DropDownList2.SelectedItem.Text;
if (Wizard1.ActiveStepIndex >= 3)
Label3.Text = "The value selected on Step 3 is: " + DropDownList3.SelectedItem.Text;
}
void GetAllValues(object sender, WizardNavigationEventArgs e)
...{
Label4.Text = "The value selected on Step 1 is: " + DropDownList4.SelectedItem.Text;
Label5.Text = "The value selected on Step 2 is: " + DropDownList5.SelectedItem.Text;
Label6.Text = "The value selected on Step 3 is: " + DropDownList6.SelectedItem.Text;
}
</ script >
< html xmlns ="http://www.w3.org/1999/xhtml" >
< head runat ="server" >
< title > Wizard Commit Model Samples </ title >
</ head >
< body >
< form id ="form1" runat ="server" >
< div >
< br />
< h2 >
Wizard Commitment Model Samples </ h2 >
< table id ="TABLE1" language ="javascript" >
< tr >
< td bgcolor ="#eff3fb" valign ="top" >
< b > Wizard Commit As You Go Sample </ b >< br />
Select items on each step and click the next button. Notice that your selection
is written out to a label each time you click a next button and that no previous
button is displayed because the AllowReturn=False is set for each step. </ td >
< td >
</ td >
< td bgcolor ="#fffbd6" valign ="top" >
< b > Wizard Commit At the End Sample </ b >< br />
Select an item on each step and click the next or finish button. Notice that all
of your selections are written out to labels after you click the finish button on
the final wizard step. You can also click the previous button and change your selection. </ td >
</ tr >
< tr >
< td bgcolor ="#eff3fb" >
< asp:Wizard ID ="Wizard1" runat ="server" ActiveStepIndex ="0" Width ="322px" OnActiveStepChanged ="GetFavoriteNumerOnActiveStepIndex"
BackColor ="#EFF3FB" BorderColor ="#B5C7DE" BorderWidth ="1px" Font-Names ="Verdana"
CellPadding ="5" >
< WizardSteps >
< asp:WizardStep runat ="server" Title ="Step 1" AllowReturn ="False" >
Wizard Step 1 < br />
< br />
Favorite Number:
< asp:DropDownList ID ="DropDownList1" runat ="server" >
< asp:ListItem > 1 </ asp:ListItem >
< asp:ListItem > 2 </ asp:ListItem >
< asp:ListItem > 3 </ asp:ListItem >
< asp:ListItem > 4 </ asp:ListItem >
< asp:ListItem > 5 </ asp:ListItem >
< asp:ListItem > 6 </ asp:ListItem >
< asp:ListItem > 7 </ asp:ListItem >
< asp:ListItem > 8 </ asp:ListItem >
< asp:ListItem > 9 </ asp:ListItem >
< asp:ListItem > 10 </ asp:ListItem >
</ asp:DropDownList >
< br />
</ asp:WizardStep >
< asp:WizardStep runat ="server" Title ="Step 2" AllowReturn ="False" >
Favorite Color: < asp:DropDownList ID ="DropDownList2" runat ="server" >
< asp:ListItem > Red </ asp:ListItem >
< asp:ListItem > Blue </ asp:ListItem >
< asp:ListItem > Green </ asp:ListItem >
< asp:ListItem > Purple </ asp:ListItem >
< asp:ListItem > Black </ asp:ListItem >
< asp:ListItem > Brown </ asp:ListItem >
< asp:ListItem > Pink </ asp:ListItem >
< asp:ListItem > Orange </ asp:ListItem >
< asp:ListItem > Yellow </ asp:ListItem >
</ asp:DropDownList >
</ asp:WizardStep >
< asp:WizardStep AllowReturn ="False" ID ="Step3" runat ="server" Title ="Step 3" StepType ="Step" >
Favorite Sport:
< asp:DropDownList ID ="DropDownList3" runat ="server" >
< asp:ListItem > Soccer </ asp:ListItem >
< asp:ListItem > Baseball </ asp:ListItem >
< asp:ListItem > Football </ asp:ListItem >
< asp:ListItem > Hockey </ asp:ListItem >
< asp:ListItem > Basketball </ asp:ListItem >
< asp:ListItem > Tennis </ asp:ListItem >
< asp:ListItem > Rugby </ asp:ListItem >
< asp:ListItem > Cricket </ asp:ListItem >
</ asp:DropDownList >
</ asp:WizardStep >
< asp:WizardStep ID ="Complete" runat ="server" Title ="Complete " StepType ="Complete" >
< br />
Thank you for completing this survey. < br />
</ asp:WizardStep >
</ WizardSteps >
< StepStyle Font-Size ="0.8em" ForeColor ="#333333" />
< SideBarStyle BackColor ="#507CD1" Font-Size ="0.9em" VerticalAlign ="Top" />
< NavigationButtonStyle BackColor ="White" BorderColor ="#507CD1" BorderStyle ="Solid"
BorderWidth ="1px" Font-Names ="Verdana" Font-Size ="0.8em" ForeColor ="#284E98" />
< SideBarButtonStyle BackColor ="#507CD1" Font-Names ="Verdana" ForeColor ="White" />
< HeaderStyle BackColor ="#284E98" BorderColor ="#EFF3FB" BorderStyle ="Solid" BorderWidth ="2px"
Font-Bold ="True" Font-Size ="0.9em" ForeColor ="White" HorizontalAlign ="Center" />
</ asp:Wizard >
</ td >
< td >
</ td >
< td bgcolor ="#fffbd6" >
< asp:Wizard ID ="Wizard2" runat ="server" ActiveStepIndex ="0" Width ="322px" OnFinishButtonClick ="GetAllValues"
BackColor ="#FFFBD6" BorderColor ="#FFDFAD" BorderWidth ="1px" Font-Names ="Verdana"
Font-Size ="0.8em" CellPadding ="5" >
< WizardSteps >
< asp:WizardStep runat ="server" Title ="Step 1" >
Wizard Step 1 < br />
< br />
Favorite Number:
< asp:DropDownList ID ="DropDownList4" runat ="server" >
< asp:ListItem > 1 </ asp:ListItem >
< asp:ListItem > 2 </ asp:ListItem >
< asp:ListItem > 3 </ asp:ListItem >
< asp:ListItem > 4 </ asp:ListItem >
< asp:ListItem > 5 </ asp:ListItem >
< asp:ListItem > 6 </ asp:ListItem >
< asp:ListItem > 7 </ asp:ListItem >
< asp:ListItem > 8 </ asp:ListItem >
< asp:ListItem > 9 </ asp:ListItem >
< asp:ListItem > 10 </ asp:ListItem >
</ asp:DropDownList >
< br />
</ asp:WizardStep >
< asp:WizardStep runat ="server" Title ="Step 2" >
Favorite Color: < asp:DropDownList ID ="DropDownList5" runat ="server" >
< asp:ListItem > Red </ asp:ListItem >
< asp:ListItem > Blue </ asp:ListItem >
< asp:ListItem > Green </ asp:ListItem >
< asp:ListItem > Purple </ asp:ListItem >
< asp:ListItem > Black </ asp:ListItem >
< asp:ListItem > Brown </ asp:ListItem >
< asp:ListItem > Pink </ asp:ListItem >
< asp:ListItem > Orange </ asp:ListItem >
< asp:ListItem > Yellow </ asp:ListItem >
</ asp:DropDownList >
</ asp:WizardStep >
< asp:WizardStep runat ="server" Title ="Step 3" >
Favorite Sport:
< asp:DropDownList ID ="DropDownList6" runat ="server" >
< asp:ListItem > Soccer </ asp:ListItem >
< asp:ListItem > Baseball </ asp:ListItem >
< asp:ListItem > Football </ asp:ListItem >
< asp:ListItem > Hockey </ asp:ListItem >
< asp:ListItem > Basketball </ asp:ListItem >
< asp:ListItem > Tennis </ asp:ListItem >
< asp:ListItem > Rugby </ asp:ListItem >
< asp:ListItem > Cricket </ asp:ListItem >
</ asp:DropDownList >
</ asp:WizardStep >
< asp:WizardStep runat ="server" StepType ="Complete" Title ="Complete " >
< br />
Thank you for completing this survey. < br />
</ asp:WizardStep >
</ WizardSteps >
< SideBarStyle BackColor ="#990000" Font-Size ="0.9em" VerticalAlign ="Top" />
< NavigationButtonStyle BackColor ="White" BorderColor ="#CC9966" BorderStyle ="Solid"
BorderWidth ="1px" Font-Names ="Verdana" Font-Size ="0.8em" ForeColor ="#990000" />
< SideBarButtonStyle ForeColor ="White" />
< HeaderStyle BackColor ="#FFCC66" BorderColor ="#FFFBD6" BorderStyle ="Solid" BorderWidth ="2px"
Font-Bold ="True" Font-Size ="0.9em" ForeColor ="#333333" HorizontalAlign ="Center" />
</ asp:Wizard >
</ td >
</ tr >
< tr >
< td bgcolor ="#eff3fb" >
< asp:Label ID ="Label1" runat ="server" ></ asp:Label >< br />
< br />
< asp:Label ID ="Label2" runat ="server" ></ asp:Label >< br />
< br />
< asp:Label ID ="Label3" runat ="server" ></ asp:Label ></ td >
< td >
</ td >
< td bgcolor ="#fffbd6" >
< asp:Label ID ="Label4" runat ="server" ></ asp:Label >< br />
< br />
< asp:Label ID ="Label5" runat ="server" ></ asp:Label >< br />
< br />
< asp:Label ID ="Label6" runat ="server" ></ asp:Label ></ td >
</ tr >
</ table >
< br />
< br />
< br />
< br />
< br />
< br />
< br />
< br />
< br />
< br />
< br />
< br />
< br />
< br />
</ div >
</ form >
</ body >
</ html >
参考:
1、http://aspalliance.com/769_Walking_with_a_Wizard
2、http://quickstart.developerfusion.co.uk/QuickStart/aspnet/doc/ctrlref/standard/wizard.aspx