“Microsoft JScript运行时错误:无法获取属性'html'的值:

问题描述 投票:0回答:1

如果会话超时,我试图弹出一条消息,并且我的控制器会返回一些错误消息。

我的内容如下......

<link rel="stylesheet" type="text/css" href="<%= ResolveUrl("~/Content/jqueryui/redmond/jquery-ui-1.8.16.custom.css") %>"/>
<link rel="stylesheet" type="text/css" href="<%= ResolveUrl("~/css/slideshow.css") %>"/>   
<script type="text/javascript" src="<%= Url.Content("~/Scripts/ui/jquery-1.6.2.js") %>"></script>
<script type="text/javascript" src="<%= Url.Content("~/Scripts/ui/jquery-ui-1.8.16.custom.js") %>"></script>

这是代码:

<% 
        string AlertMessage2 = TempData["PublicAlertMessage"] as string;
        string AlertMessage2Title = TempData["AlertMessageTitle"] == null ? String.Empty : TempData["AlertMessageTitle"] as string;

        if( AlertMessage2 != null )
        { %>
          <div id="AlertMessage" title="">

             </div>
         <script type="text/javascript">
             jQuery.noConflict();
                 $("#AlertMessage").html("<center><%= AlertMessage2 %></center>");
                 $("#AlertMessage").dialog({ height: 240, width: 350, modal: true, title: '<%= AlertMessage2Title %>', buttons: { "OK": function () { $(this).dialog("close"); } } });

             });
          </script>

      <% } %>

我得到“Microsoft JScript运行时错误:当我实现以下Jquery对话框时,无法获取属性'html'的值:对象为null或未定义”。

我错过了任何包含文件吗?我不知道在哪里看!有任何想法吗?

谢谢!

现在我可以看到模态窗口...但是在ok按钮中收到错误“Microsoft JScript运行时错误:对象不支持属性或方法'对话框'”

这是在IE 9中。当我尝试使用Google Chrome时,我无法关闭模态窗口。

$("#AlertMessage").dialog({
                     height: 200,
                     width: 250,
                     modal: true,
                     title: '<%= AlertMessage2Title %>',
                     buttons: { "OK": function () { 
                    // $(this).dialog('close'); --> comment this and try to run... no issues
                     } } });

按钮有什么问题?

29日更新:如果我删除ok的关闭功能,则没有错误。但是如何关闭模态窗口?还有其他工作吗?

12月2日更新:此代码在IE 8和IE 9中不起作用。此外,弹出窗口不会关闭。但IE 7没问题。

jquery asp.net-mvc-2
1个回答
0
投票

我想你错过了jQuery Ui对话框使用的依赖项:

UI Core
**UI Position**
UI Widget
UI Mouse (Optional; only needed if using UI Draggable or UI Resizable)
UI Draggable (Optional)
UI Resizable (Optional)

http://jqueryui.com/demos/dialog/

如果要包含整个jQuery UI套件,可以创建一个唯一的文件并将其包含在内。

© www.soinside.com 2019 - 2024. All rights reserved.