[英]updating a user control in an asp.net update panel (based upon action in another user control)
I have 2 Update Panels, as shown below, on an aspx page.我在 aspx 页面上有 2 个更新面板,如下所示。 The aspx page uses a UserControl element, which implements a repeater with a list of page numbers displayed on it. aspx 页面使用 UserControl 元素,该元素实现了一个带有显示在其上的页码列表的转发器。 There are 2 lists of page numbers, say L1 ans L2, one at the top of the page and one at the bottom.有 2 个页码列表,比如 L1 和 L2,一个在页面顶部,一个在底部。 (Hence, the 2 User Controls, RevPaging1 and RevPaging2 on the aspx page). (因此,aspx 页面上的 2 个用户控件,RevPaging1 和 RevPaging2)。
<%@ Register Src="../Controls/UseControl.ascx" TagName="UserControl" TagPrefix="uc1" %>
<asp:UpdatePanel runat="server" ID="UpdatePanel1" UpdateMode="Conditional">
<ContentTemplate>
<div id="Div1" class="paging" runat="server" visible="false">
<uc1:UserControl id="RevPaging1" runat="server" ShowResult="false">
</uc1:UserControl>
</div>
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdatePanel runat="server" ID="UpdatePanel2" UpdateMode="Conditional">
<ContentTemplate>
<div id="Div2" class="paging" runat="server" visible="false">
<uc1:UserControl id="RevPaging2" runat="server" ShowResult="false">
</uc1:UserControl>
</div>
</ContentTemplate>
</asp:UpdatePanel>
Question: How do I make sure that when I click on any page number on "RevPaging1" , the page number is automatically updated on "RevPaging2" to the same number that i selected on RevPaging1(one that I did not click on) and similarly, when I click on any page number on "RevPaging2" the page number is automatically updated on "RevPaging1" (one that I did not click on).问题:我如何确保当我点击“RevPaging1”上的任何页码时,“RevPaging2”上的页码会自动更新为我在 RevPaging1 上选择的相同数字(我没有点击),类似地,当我点击“RevPaging2”上的任何页码时,“RevPaging1”(我没有点击的那个)上的页码会自动更新。
Following is the implementation of the UserControl (which is declared twice inside the the 2 update panels above).以下是 UserControl 的实现(在上面的 2 个更新面板中声明了两次)。
<%@ Control Language="C#" AutoEventWireup="true"
CodeBehind="UserControl.ascx.cs" Inherits="Namespace.UserControl" %>
<table>
<tr>
<td class="left">
<p class="button2Left"></p>
<asp:Button ID="btPreviousPage" runat="server" cssclass="button2"
OnClick="btPreviousPage_Click" Text="Previous Page" />
<p class="button2Right"></p>
</td>
<td class="middle">
<asp:Repeater ID="pageNumbers" runat="server" OnItemCommand="pageNumbers_ItemCommand">
<HeaderTemplate>
<ul>This is the header template</ul>
</HeaderTemplate>
<ItemTemplate>
<li class='<%#DataBinder.Eval(Container.DataItem,"PCssClass")%>'>
<asp:LinkButton ID="LinkButton1" CommandName="prefixLink"
CommandArgument='<%#DataBinder.Eval(Container.DataItem,"PText")%>'
runat="server"
Text='<%#DataBinder.Eval(Container.DataItem,"PText")%>' />
</li>
</ItemTemplate>
<FooterTemplate>
<ul>This is the footer template</ul>
</FooterTemplate>
</asp:Repeater>
</td>
<td class="right">
<p class="button2Left"></p>
<asp:Button ID="btNextPage" cssclass="button2" runat="server" OnClick="btNextPage_Click" Text="Next Page" />
<p class="button2Right"></p>
</td>
</tr>
</table>
当您处理点击控件中的页码的事件时,有一个单独的功能可以用数据更新两个面板/控件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.