-1

I have 2 Update Panels, as shown below, on an aspx page. The aspx page uses a UserControl element, which implements a repeater with a list of page numbers displayed on it. There are 2 lists of page numbers, say L1 ans L2, one at the top of the page and one at the bottom. (Hence, the 2 User Controls, RevPaging1 and RevPaging2 on the aspx page).

<%@ 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).

Following is the implementation of the UserControl (which is declared twice inside the the 2 update panels above).

<%@ 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>
4

1 回答 1

0

当您处理单击控件中的页码的事件时,有一个单独的函数可以使用数据更新两个面板/控件。

于 2012-11-26T23:44:12.837 回答