【问题标题】:UpdatePanel initial callUpdatePanel 初始调用
【发布时间】:2009-05-12 14:55:58
【问题描述】:

我在 asp.net 页面中使用 UpdatePaenl。 它有一个按钮来触发它。按下按钮时,我可以显示“正在加载”。 这是我的问题:我需要它在第一次调用页面时显示“正在加载”,而不仅仅是在按下按钮时。

我想当页面首次加载时,JavaScript 将用于触发 UpdatePanel。

非常感谢任何想法。谢谢

【问题讨论】:

    标签: asp.net javascript


    【解决方案1】:

    您应该能够在 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;
        }
    }
    

    在 ASP 中设置文字如下:

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

    更多信息见 MSDN:http://msdn.microsoft.com/en-us/library/bb311028.aspx

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多