简体   繁体   English

UpdatePanel初始调用

[英]UpdatePanel initial call

I am using an UpdatePaenl in an asp.net page. 我在asp.net页面中使用UpdatePaenl。 It has a button to trigger it. 它有一个按钮来触发它。 I'm able to show "Loading" when the button is pressed. 按下按钮后,我可以显示“正在加载”。 Here's my issue: I need it to show "Loading" when the page is first called, not just when a button is pressed. 这是我的问题:我需要它在首次调用页面时显示“正在加载”,而不仅仅是在按下按钮时显示。

I would imagine that JavaScript would be used to trigger the UpdatePanel when the page is first loaded. 我可以想象一下,当页面首次加载时,将使用JavaScript触发UpdatePanel。

Any ideas are greatly appreciated. 任何想法都将不胜感激。 Thanks 谢谢

You should be able to do this in javascript by setting up an event to fire after the page is loaded: 您应该可以通过设置页面加载后触发的事件在javascript中执行此操作:

// Define the pg_Loaded() function as the handler for the PageLoaded event
Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(pg_Loaded);

var blnFirstPageVisit = true;

function pg_Loaded() 
{
    if (blnFirstPageVisit == true) 
    {
        // Display loading animation
        fnToggleLoading();

        // Trigger button postback event
        <asp:literal runat="server" id="ltlExecute" />

        // Prevent this from firing a second time after the postback completes
        blnFirstPageVisit = false;
    }
}

In ASP set the literal text like so: 在ASP中设置文字文本,如下所示:

ltlExecute.Text = ClientScript.GetPostBackEventReference(btnExecute, "")

More information exists at MSDN: http://msdn.microsoft.com/en-us/library/bb311028.aspx MSDN上存在更多信息: http : //msdn.microsoft.com/zh-cn/library/bb311028.aspx

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

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