我在我的页面上使用 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>