0

我在我的页面上使用 asp:UpdateProgress 控件,并希望在多个页面上使用相同的控件,但不复制和粘贴代码。我无法通过将面板粘贴到用户控件中并将用户控件拖放到页面上来使其工作。但我不熟悉用户控件,所以希望它很简单。

UserControl .ascx 文件内容

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="AjaxProgressLoader.ascx.cs" Inherits="MyNamespace.Controls.AjaxProgressLoader" %>
    <asp:UpdateProgress runat="server" ID="PageUpdateProgress">
    <ProgressTemplate>
        <div id="Imgt" style="position: absolute; left: 0; top: 0; width: 100%; height: 100%;"
            align="center" valign="middle" runat="server" class="blur">
            <table width="100%">
                <tr>
                    <td>
                        <img src="/Styles/Images/ajax_loader.gif" style="position: relative; horiz-align: center;
                            vert-align: middle; margin-top: 100px" width="75px" />
                    </td>
                </tr>
                <tr>
                    <td style="color: #FFFFFF">
                        Loading...
                    </td>
                </tr>
            </table>
        </div>
    </ProgressTemplate>
</asp:UpdateProgress>

.aspx 主页面

<%@ Register TagPrefix="ajax" TagName="AjaxUpdateProgress" Src="~/Controls/AjaxProgressLoader.ascx" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<asp:ScriptManager ID="uxScriptManager" runat="server"></asp:ScriptManager>
<ajax:AjaxUpdateProgress ></ajax:AjaxUpdateProgress>
<asp:UpdatePanel runat="server" ID="Panel">
<ContentTemplate>
My Content...
</ContentTemplate>
</asp:UpdatePanel>
4

1 回答 1

0

解决方案:我的用户控件进度模板上缺少 AssociatedUpdatePanelId。我可以将其定义如下并将我的所有面板称为“面板”。

 <asp:UpdateProgress runat="server" ID="PageUpdateProgress" AssociatedUpdatePanelID="Panel">

感谢此链接帮助我在父页面中为 UpdatePanel 的用户控件中的 ASP.NET AJAX UpdateProgress

于 2012-11-08T21:53:31.403 回答