UpdatePanel仅更新初始部分回发

本文关键字:始部 更新 UpdatePanel | 更新日期: 2023-09-27 18:08:15

我有一个母版页,其中有各种占位符,用于加载不同内容的用户控件。标题是一个,主页内容是另一个。在主内容用户控件中,它根据需要显示的页面加载各种其他用户控件。

主页

<%@ Master Language="C#" AutoEventWireup="true" EnableViewState="true" CodeBehind="Admin.Master.cs" Inherits="SitefinityWebApp.Admin" %>
<%@ Import Namespace="SitefinityWebApp.Model.Session" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
</head>
<body>
    <form id="form1" runat="server">
        <!-- start of header -->
        <section id="header">
            <asp:ContentPlaceHolder ID="cph_header" runat="server" />
        </section>
        <!-- Site  Content -->
        <section id="contentWrapper">
            <asp:ContentPlaceHolder ID="cph_content" runat="server" />
        </section>
    </form>
</body>
</html>

下面的页面被加载到内容

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="CorpPendingApproval.ascx.cs" Inherits="SitefinityWebApp.userctrls.Admin.Dashboard.Corporate.CorpPendingApproval" %>
<asp:UpdatePanel ID="PendingApprovalList" UpdateMode="Always" runat="server">
    <ContentTemplate>
        <asp:HiddenField ID="hf_currentPage" runat="server" value="0" />
        <asp:HiddenField ID="hf_totalResults" runat="server" value="0" />
        <h2>Pending Approvals</h2>
        <div class="corporateAdminPagination">
            <a ID="topPageBack" class="leftArrow" runat="server" onserverclick="PageBack"></a>
            <asp:Label ID="topCurrentPageInfo" Text="" runat="server" />
            <a ID="topPageForward" class="rightArrow" runat="server" onserverclick="PageForward"></a>
        </div>
        <!-- Table Start -->
        <table class="corporateAdminPendingApprovals" cellspacing="0">
            <!-- Table Heading -->
            <!-- Example Binding Setup -->
            <asp:Repeater ID="LowPriority" runat="server">
                <ItemTemplate>
                    <tr class="pendingApprovalListItem" 
                        <!-- Repeater Bindings Here -->
                    </tr>
                </ItemTemplate>
            </asp:Repeater>
            <!-- Table Footer -->
            <tr class="pendingApprovalsFooter">
                <!-- Footer Pagination -->
                <td width="221" class="corporateAdminPagination">
                    <a ID="bottomPageBack" class="leftArrow" runat="server" onserverclick="PageBack"></a>
                    <asp:Label ID="bottomCurrentPageInfo" Text="" runat="server" />
                    <a ID="bottomPageForward" class="rightArrow" runat="server" onserverclick="PageForward"></a>
                </td>               
            </tr>
        </table>
        <!-- Table End -->        
    </ContentTemplate>
</asp:UpdatePanel>

上述用户控件的代码

namespace SitefinityWebApp.userctrls.Admin.Dashboard.Corporate {
    public partial class CorpPendingApproval : System.Web.UI.UserControl {
        public int CurrentPage {
            get {
                return int.Parse(hf_currentPage.Value);
            }
            set {
                hf_currentPage.Value = value.ToString();
            }
        }
        public int TotalResults {
            get {
                return int.Parse(hf_totalResults.Value);
            }
            set {
                hf_totalResults.Value = value.ToString();
            }
        }
        //Sets default page values for pagination results
        protected void Page_Load(object sender, EventArgs e) {
            if (!IsPostBack) {
                CurrentPage = 0;
                TotalResults = GetResultSetCount();
                PopulatePageInfoTexts();
                PopulatePageWithResultSet();
            }
        }
        //Returns the count of the entire result set
        private int GetResultSetCount() {
            //Returns List<T>
            //Omitted for brevity
        }
        //Moves the pagination back one page
        protected void PageBack(object sender, EventArgs e) {
            if (CurrentPage > 0) {
                CurrentPage--;
                PopulatePageInfoTexts();
                PopulatePageWithResultSet();
            }
        }
        //Moves the pagination forward one page
        protected void PageForward(object sender, EventArgs e) {
            if (CurrentPage < (int)(TotalResults / ((CurrentPage + 1) * 20))) {
                CurrentPage++;
                PopulatePageInfoTexts();
                PopulatePageWithResultSet();
            }
        }
        //Displays info about number of results/pages for pagination
        private void PopulatePageInfoTexts() {
            //Logic omitted for brevity
        }
        //Displays result set based on current viewing page
        private void PopulatePageWithResultSet() {
            //Logic omited for brevity
            //Bind to repeaters
            TopPriority.DataSource = topPriority;
            TopPriority.DataBind();
        }
    }
}

基本上,当单击pageForward或pageBack按钮时,它会更改隐藏字段中的值,并使用新的偏移量从DB请求数据,并将该数据绑定到UpdatePanel中的Repeater。我希望它调用服务器,增加当前页面,并显示新的结果。这只适用于第一次点击任何按钮。之后,在Chrome的DevTools中查看网络调用和响应时,HTML正确返回,但HTML从未在第一次发布后重新渲染在页面上…?

当这个开始发生时抛出一个错误,它来自jquery.cookie.js。这个文件的包含在整个项目中找不到,所以我猜SiteFinity将它包含在某个捆绑的dll中。我不知道这是否是问题的根本原因,但我希望这与它有关。下面是出现在DevTools

中的错误
Uncaught TypeError: undefined is not a function: Telerik.Web.UI.WebResource.axd?_TSM_HiddenField_=ctl09_TSM&compress=0&_TSM_CombinedScripts_=%3b%3bT…:559
_checkBrowseAndEditState:function(){browseAndEditState=jQuery.cookie(this._browseAndEditCookieName);

提前感谢您的帮助!

UpdatePanel仅更新初始部分回发

出于某种原因,SiteFinity需要jQuery Cookie插件,但没有列为资源。包括jQuery Cookie和一切都很好。