我在button
AddPostUserControl 中有user control
。我希望当button
AddPostUserControl 中的user control
点击事件触发时,找到ID为 ShowPostsListView 的asp:ListView
。我怎么能这样做?
<%--add post user control--%>
<uc1:AddPostUserControl runat="server" id="AddPostUserControl" />
<%--show posts--%>
<asp:ListView ID="ShowPostsListView" runat="server">
<ItemTemplate>
<div class="thisPost">
<div class="thisPostAuthor">
<%# this.GetCurrentUser(Eval("User")) %>
</div>
<div class="thisPostHeader">
<h3>
<%# Eval("Title") %>
</h3>
<span class="postDateTime">
<%# Eval("PostDate") %>
</span>
</div>
<div class="thisPostContent">
<p>
<%# Eval("PostContent") %>
</p>
</div>
</div>
</ItemTemplate>
</asp:ListView>
答案 0 :(得分:1)
Page page = HttpContext.Current.Handler as Page
ListView lsv = page.FindControl("ShowPostsListView");