我有一個DIV我的中繼器內,如下所示:如何切換中繼器中DIV的可見性?
<asp:Repeater ID="topicView" runat="server" OnItemCommand="Delete_ItemCommand">
<ItemTemplate>
<table width="945px" cellpadding="0" cellspacing="0" border="0" class="post-table">
<tr>
<td colspan="2">
<div class="post-info">
<div class="post-info-left"><%#DataBinder.Eval(Container.DataItem, "PostDate")%></div>
<div class="post-info-right">#<%#DataBinder.Eval(Container.DataItem, "PostID")%></div>
<div class="clear"></div>
</div>
</td>
</tr>
<tr>
<td class="post-left">
<p><strong><%#DataBinder.Eval(Container.DataItem, "Username")%></strong></p>
</td>
<td class="post-right">
<p><%#DataBinder.Eval(Container.DataItem, "PostBody")%></p>
</td>
</tr>
<tr>
<td colspan="2">
<div class="post-edit">
<p id="postEditAdmin" runat="server" visible="false"><a class="fancybox.iframe fancybox" href='editpost.aspx?postID=<%#DataBinder.Eval(Container.DataItem, "PostID")%>'>Edit</a> | <asp:LinkButton ID="deleteBtn" runat="server" Text="Delete" CommandName="Delete" OnClientClick="javascript:if(!confirm('Delete this information? this will delete permanently'))return false;" CommandArgument='<%#DataBinder.Eval(Container.DataItem, "PostID")%>' /></p>
<p id="postEdit" runat="server" visible="true"><i>You must be an admin to be able to edit or delete a post</i></p>
</div>
</td>
</tr>
</table>
</ItemTemplate>
</asp:Repeater>
任何人都可以讓我知道如何將postEditAdmin.Visible設置爲true,postEdit.Visible假?它不會在頁面加載中被拾取。
另請注意,它將根據if語句進行更改。這是我到目前爲止:
if (Session["role"].ToString() == "2")
{
postEditAdmin.Visible = true;
postEdit.Visible = false;
}
嘗試在標記中包裝每個標記並在其中設置可見性。 (我認爲它可能是多個HTML服務器控件,導致該問題的ID相同。) –
McGarnagle