简体   繁体   English

Microsoft JScript运行时错误:“null”为null或不是对象

[英]Microsoft JScript runtime error: 'null' is null or not an object

I have application like where i can create dynamic tabs. 我有应用程序,我可以在哪里创建动态标签。 and delete cross bar option on tabs. 并删除选项卡上的横杆选项。 When I am trying to delete the tab I am getting error like 当我试图删除选项卡时,我收到错误

Microsoft JScript runtime error: 'null' is null or not an object and point to my Javascript code. Microsoft JScript运行时错误:'null'为null或不是对象并指向我的Javascript代码。

Here is my JS code. 这是我的JS代码。

  <script type="text/javascript">
        /* <![CDATA[ */
        function deleteTab(tabText)
        {
            var tabStrip = $find("<%= RadTabStrip1.ClientID %>");
            var multiPage = $find("<%= RadMultiPage1.ClientID %>");
            var tab = tabStrip.findTabByText(tabText);
            var pageView = tab.get_pageView();

            var tabToSelect = tab.get_nextTab();
            if (!tabToSelect)
                tabToSelect = tab.get_previousTab();

            tabStrip.get_tabs().remove(tab);
            multiPage.get_pageViews().remove(pageView);

            if (tabToSelect)
                tabToSelect.set_selected(true);
        }
        /* ]]> */
</script>

and in page lode 并在页面lode

    if (!Page.IsPostBack)
    {
        RadTab tab = new RadTab();
        tab.Text = string.Format("New Page {0}", 1);
        RadTabStrip1.Tabs.Add(tab);

        RadPageView pageView = new RadPageView();
        pageView.Height = new Unit("50px");
        pageView.Width = new Unit("1300px");
        RadMultiPage1.PageViews.Add(pageView);

        BuildPageViewContents(pageView, RadTabStrip1.Tabs.Count);
        RadTabStrip1.SelectedIndex = 0;

    }

You're not checking any of those function calls to see if they're actually returning something. 你没有检查任何这些函数调用,看看他们是否真的返回了一些东西。 One of them is returning null , but your code does not notice that and tries to use the result in a subsequent statement. 其中一个是返回null ,但是您的代码没有注意到并尝试在后续语句中使用结果。

Try this in Firefox with Firebug and you'll probably get better error messages. 在Firefox中使用Firebug尝试此操作,您可能会得到更好的错误消息。

This error can occur if you are trying to use an object which is null . 如果您尝试使用null对象,则会发生此错误。 In that code quite a lot of things can return null : $find, findTabByText, getPageView, get_nextTab, get_previousTab etc. I suggest you alert() everything before using it. 在该代码中,很多东西都可以返回null$find, findTabByText, getPageView, get_nextTab, get_previousTab等。我建议你在使用之前提醒()所有内容。 That way you will find what is null . 这样你就会发现什么是null

$find can return null if you are trying to call it too early. 如果你试图过早地调用它,$ find可以返回null。 Remember that ASP.NET AJAX controls are created during the Sys.Application.Init event. 请记住,ASP.NET AJAX控件是在Sys.Application.Init事件期间创建的。 If you try to access them earlier (eg in the window.onload) the $find() will not work. 如果你之前尝试访问它们(例如在window.onload中),$ find()将无效。

暂无
暂无

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

相关问题 Microsoft JScript运行时错误:“ data.EmployeeDetails.EmployeeId”为null或不是对象` - Microsoft JScript runtime error: 'data.EmployeeDetails.EmployeeId' is null or not an object` Microsoft JScript 运行时错误:'Sys.Extended.UI' 是 null 或者不是 object - Microsoft JScript runtime error: 'Sys.Extended.UI' is null or not an object Microsoft JScript运行时错误:无法获取属性&#39;removeChild&#39;的值:对象为null或未定义 - Microsoft JScript runtime error: Unable to get value of the property 'removeChild': object is null or undefined Microsoft JScript运行时错误:无法获取属性“样式”的值:对象为null或未定义 - Microsoft JScript runtime error: Unable to get value of the property 'style': object is null or undefined Microsoft JScript运行时错误:预期对象 - Microsoft JScript runtime error: Object expected jQuery“Microsoft JScript运行时错误:对象预期” - jQuery “Microsoft JScript runtime error: Object expected” Microsoft JScript运行时错误:对象不支持此属性或方法 - Microsoft JScript runtime error: Object doesn't support this property or method Microsoft JScript运行时错误:对象不支持此属性或方法 - Microsoft JScript runtime error: Object doesn't support this property or method BHO插件(Microsoft JScript运行时错误) - BHO Plugin (Microsoft JScript runtime error) Microsoft JScript运行时错误:“ clientUploadComplete”未定义 - Microsoft JScript runtime error: 'clientUploadComplete' is undefined
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM