【发布时间】:2020-02-27 15:02:35
【问题描述】:
如果会话超时并且我的控制器返回一些错误消息,我会尝试弹出一条消息。
我的包含如下......
<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>
<% } %>
当我实现以下 Jquery 对话框时,我收到“Microsoft JScript 运行时错误:无法获取属性 'html' 的值:对象为空或未定义”。
我是否缺少任何包含文件?我不知道在哪里看!有什么想法吗?
谢谢!
现在我可以看到模态窗口...但是在确定按钮中出现错误“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 UI 包含为八个独立的 JavaScript 文件而不是一个?
-
另外:
<center>标签是 1997 年的。
标签: jquery asp.net-mvc-2