【问题标题】:Error: Unable to get property '_ScriptLoaderTask' of undefined or null reference错误:无法获取未定义或空引用的属性“_ScriptLoaderTask”
【发布时间】:2018-12-04 10:51:17
【问题描述】:

为什么在 ASP 中尝试使用 ScriptManager 和 JavaScript 关闭 RadWindow 时会抛出 Error: Unable to get property '_ScriptLoaderTask' of undefined or null referece(Internet Explorer 11)

我们的应用程序具有“保存和关闭”按钮,其中包含以下 C# 代码,用于在保存完成后执行关闭逻辑:

public void CloseWindow()
{
    ScriptManager.RegisterStartupScript(this, this.GetType(), "close", 
        "CloseModal()", true);
}

.aspx 页面包含以下 JavaScript

function CloseModal() {
    var oWnd = GetRadWindow();
    if (oWnd) {
        oWnd.close();
    }
}

function GetRadWindow() {
    var oWindow = null;
    if (window.radWindow) {
        oWindow = window.radWindow;
    } else if (window.frameElement &&
        window.frameElement.radWindow) {
        oWindow = window.frameElement.radWindow;
    }
    return oWindow;
}

【问题讨论】:

    标签: javascript c# asp.net telerik scriptmanager


    【解决方案1】:

    在调用 RadWindow .close() 函数之前添加 setTimeout() 一秒钟似乎可以解决问题。我相信这让ScriptManager.RegisterStartupScript 有足够的时间来完成执行。

    以下 JavaScript 是该问题的解决方案,并阻止错误模式显示发布“保存并关闭”按钮单击:

    function CloseModal() {
        var oWnd = GetRadWindow();
        if (oWnd) {
            setTimeout(function () {
                oWnd.close();
            }, 1000);
        }
     }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-08-01
      • 2020-04-28
      • 2016-08-16
      • 2017-05-18
      • 1970-01-01
      • 2014-08-29
      • 1970-01-01
      相关资源
      最近更新 更多