0
我想根據條件從我的中繼器添加/刪除onclick屬性。我如何訪問數據綁定事件中的每個人以刪除或添加該屬性?如何在asp.net中動態添加/刪除HTML屬性
<asp:repeater id="repLinks" runat="server">
<itemtemplate>
<div id="vehicle-link-<%# Eval("ID")%>" class="vehicle-link">
<a class="btn <%=IIf(Listing.IsResponsive, "btn-default", "accent-color1 palette-bg2 palette-border2")%>" href="<%# Eval("Href")%>" target="<%# Eval("Target") %>" onclick="<%# Eval("OnClick")%>"><%# Eval("Label")%></a>
</div>
</itemtemplate>
</asp:repeater>
Private Sub repLinks_OnItemDataBound(sender As Object, e As RepeaterItemEventArgs) Handles repLinks.ItemDataBound
dim row As HtmlTableRow= CType(e.Item.FindControl("repLinks"), HtmlTableRow)
if (not row is Nothing)
row.Attributes("onmouseover") = string.Format("alert('Hello from row #{0}');", e.Item.ItemIndex)
End If
End Sub
您試圖添加onclick功能的元素是什麼? –
@AdamCarr現在我試圖從項目模板中的每個錨標記中刪除它 – Cowmoogun