简体   繁体   English

asp.net页面“页面正在加载”

[英]asp.net page “page is loading”

当页面正在加载(检索数据等)时,如何显示通常在asp.net页面中看到的圆形旋涡图像?

If you're using UpdateProgress/UpdatePanel, here are some samples: http://www.asp.net/Ajax/Documentation/Live/overview/UpdateProgressOverview.aspx 如果您使用的是UpdateProgress / UpdatePanel,下面是一些示例: http : //www.asp.net/Ajax/Documentation/Live/overview/UpdateProgressOverview.aspx

Here is a loading gif sample using UpdateProgress: 这是使用UpdateProgress的加载gif示例:

<asp:UpdateProgress ID="updProg" AssociatedUpdatePanelID="updPnl" DisplayAfter="0" runat="server">
    <ProgressTemplate>
        <div id="progInd">
            <img id="indic" src="/images/loadgifs/z.gif" alt="..." />
        </div>
    </ProgressTemplate>
</asp:UpdateProgress>  

<asp:ScriptManager ID="sm" runat="server" />

<asp:UpdatePanel ID="updPnl" runat="server">
<ContentTemplate>
        ...
    <asp:Timer ID="tmrTrigPostbk" runat="server" Interval="10" />
</ContentTemplate>
<Triggers>
    <asp:AsyncPostBackTrigger ControlID="tmrTrigPostbk" EventName="Tick" />
</Triggers>    
</asp:UpdatePanel>

protected void Page_Load(object sender, EventArgs e)
{
    tmrTrigPostbk.Enabled = !IsPostBack;
}

Are you using UpdatePanel? 您正在使用UpdatePanel吗? or Are you using Javascript libraries like Jquery? 或者您是否正在使用Javascript库(例如Jquery)? If former then you can add the swirl to UpdateProgress if the latter (JQuery) then you can trigger the image on .ajaxStart() method. 如果是前者,则可以将漩涡添加到UpdateProgress(如果是后者,则是JQuery),则可以在.ajaxStart()方法上触发图像。

HTH HTH

I use the jQuery BlockUI plugin to make this pretty easy to do, even inside an area on the page, say a dialog box. 我使用jQuery BlockUI插件使此操作非常容易,即使是在页面上的某个区域内,例如一个对话框。

http://malsup.com/jquery/block/ http://malsup.com/jquery/block/

here is an example making an AJAX call to the server: 这是对服务器进行AJAX调用的示例:

    function GetNewContactInfo(contactId) {

    if (0 === contactId) {
        showErrorMsg('You must select a Contact to Retrieve');
        return;
    }

    var request = {
        ContactId: 0
    };

    wjBlockUI();

    request.ContactId = contactId;

    ContactServiceProxy.invoke({ serviceMethod: "GetContact",
        data: { request: request },
        callback: function(response) {
            DisplayNewContactInfo(response);
        },
        error: function(xhr, errorMsg, thrown) {
            postErrorAndUnBlockUI(xhr, errorMsg, thrown);
        }
    });

}

Inside the DisplayNeewContactInfo function I call $.unblockUI(); 在DisplayNeewContactInfo函数内部,我调用$ .unblockUI();。 to take the message away. 带走消息。 I have the actual invoking of the BlockUI call in a wrapper function: 我在包装函数中实际调用了BlockUI调用:

function wjBlockUI(msg) {

var defaultMsg = '<img src="../images/activity.gif" />';

if (null !== msg) {
    defaultMsg = msg
}

$.blockUI({ overlayCSS: { backgroundColor: '#aaa' }, message: defaultMsg });

} }

You can download the entire project these examples came from, http://professionalaspnet.com/WCFJQuery.zip 您可以从以下示例中下载这些示例的整个项目: http://professionalaspnet.com/WCFJQuery.zip

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM