你可以使用一个asp:Menu
这页纸
<asp:Menu ID="MyWizardMenu" Orientation="Horizontal" OnMenuItemClick="MyWizardMenu_MenuItemClick" runat="server">
<Items>
<asp:MenuItem Text="One" Selected="true" Value="0"></asp:MenuItem>
<asp:MenuItem Text="Two" Value="1" ></asp:MenuItem>
<asp:MenuItem Text="Three" Value="2"></asp:MenuItem>
</Items>
</asp:Menu>
<asp:Wizard ID="MyWizard" runat="server" OnNextButtonClick="MyWizard_NextButtonClick" OnPreviousButtonClick="MyWizard_PreviousButtonClick" DisplaySideBar="false">
<WizardSteps>
<asp:WizardStep ID="one" Title="One" runat="server">One</asp:WizardStep>
<asp:WizardStep ID="two" Title="Two" runat="server">Two</asp:WizardStep>
<asp:WizardStep ID="three" Title="Three" runat="server">Three</asp:WizardStep>
</WizardSteps>
</asp:Wizard>
背后的代码
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
MyWizard.ActiveStepIndex = 0;
}
}
protected void MyWizardMenu_MenuItemClick(object sender, MenuEventArgs e)
{
int index = Int32.Parse(e.Item.Value);
MyWizard.ActiveStepIndex = index;
}
protected void MyWizard_NextButtonClick(object sender, WizardNavigationEventArgs e)
{
MyWizardMenu.Items[e.NextStepIndex].Selected = true;
}
protected void MyWizard_PreviousButtonClick(object sender, WizardNavigationEventArgs e)
{
MyWizardMenu.Items[e.CurrentStepIndex - 1].Selected = true;
}
甚至应该可以绑定MyWizard.WizardSteps
到MyWizardMenu.DataSource
(以避免将您的步骤硬编码到导航项),但我还没有让它工作,因为简单地转换为 IHierachicalEnumeration 是不够的。