我试图使asp.net向导可点击链接的选项卡,但它似乎不起作用

时间:2013-12-02 15:51:25

标签: asp.net vb.net wizard

我在网上找到了一个很棒的asp.net向导模板,可以将向导步骤从一侧移到顶端。它在顶部时没有点击功能。我正在尝试使标签可点击链接,但它似乎无法正常工作。

以下是向导的片段:

<HeaderStyle BackColor="#FFCC66" BorderColor="#FFFBD6" BorderStyle="Solid" 
         BorderWidth="2px" Font-Bold="True" Font-Size="0.9em" ForeColor="#333333" 
         HorizontalAlign="Center" />

     <HeaderTemplate>
           <ul id="wizHeader">
               <asp:Repeater ID="SideBarList" runat="server">
                   <ItemTemplate>
                      <li><a class="<%# GetClassForWizardStep(Container.DataItem) %>"     
      title="<%#Eval("Name")%>">
                           <%# Eval("Name")%></a> </li>
                   </ItemTemplate>
               </asp:Repeater>
           </ul>
       </HeaderTemplate>

        <NavigationButtonStyle BackColor="White" BorderColor="#CC9966" 
         BorderStyle="Solid" BorderWidth="1px" Font-Names="Verdana" Font-Size="1.2em"
         ForeColor="#990000" CssClass="centerButtons" />

     <SideBarButtonStyle ForeColor="White" />
     <SideBarStyle BackColor="#990000" Font-Size="0.9em" VerticalAlign="Top" />
    <WizardSteps>

这里有一些代码:

Private Sub wizClaims_PreRender(sender As Object, e As System.EventArgs) Handles  
    wizClaims.PreRender
    Dim SideBarList As Repeater = 
        TryCast(wizClaims.FindControl("HeaderContainer").FindControl("SideBarList"), 
           Repeater)
    SideBarList.DataSource = wizClaims.WizardSteps
    SideBarList.DataBind()
End Sub

Public Function GetClassForWizardStep(wizardStep As Object) As String
    Dim [step] As WizardStep = TryCast(wizardStep, WizardStep)

    If [step] Is Nothing Then
        Return ""
    End If
    Dim stepIndex As Integer = wizClaims.WizardSteps.IndexOf([step])

    If stepIndex < wizClaims.ActiveStepIndex Then
        Return "prevStep"
    ElseIf stepIndex > wizClaims.ActiveStepIndex Then
        Return "nextStep"
    Else
        Return "currentStep"
    End If
End Function

我将不胜感激任何帮助: - )

1 个答案:

答案 0 :(得分:3)

我认为最简单的解决方案:

  1. 使用<linkbutton>代替<a>,以便生成回发:

    <asp:LinkButton runat="server" 
    CssClass="<%# GetClassForWizardStep(Container.DataItem) %>">
       <%# Eval("Name")%>
    </asp:LinkButton> 
    
  2. 将事件附加到转发器:

    <asp:Repeater ID="SideBarList" runat="server" 
      OnItemCommand="SideBarList_ItemCommand">
    
  3. 在后面的代码中,回复事件:

    Protected Sub SideBarList_ItemCommand(source As Object, 
                                          e As RepeaterCommandEventArgs)
      wizClaims.ActiveStepIndex = e.Item.ItemIndex
    End Sub
    
  4. 现在单击任何链接按钮将更改向导的活动步骤。