将jQueryUI链接到ASP.NETMVC2项目

将jQueryUI链接到ASP.NETMVC2项目,jquery,asp.net-mvc,jquery-ui,Jquery,Asp.net Mvc,Jquery Ui,我试图实现的是从我自己的JavaScript源代码文件中使用jQueryUI对话框方法。我在网站上有这样的链接 <script src="/Scripts/jquery-1.4.2.js" type="text/javascript"></script> <script src="/Scripts/jquery.validate.js" type="text/javascript"></script> <script src="/Script

我试图实现的是从我自己的JavaScript源代码文件中使用jQueryUI对话框方法。我在网站上有这样的链接

<script src="/Scripts/jquery-1.4.2.js" type="text/javascript"></script>
<script src="/Scripts/jquery.validate.js" type="text/javascript"></script>
<script src="/Scripts/jquery-ui.js" type="text/javascript"></script>
<script src="/Scripts/Common.js" type="text/javascript"></script>  
我将得到“Microsoft JScript运行时错误:对象不支持此属性或方法”

你知道为什么会这样吗?jQuery工作得很好,但jQueryUI不行


附加问题:如果我使用jquery-ui.js,我是否需要其他文件,如core、dialog等,或者它是否真的包含所有内容?

您能否确认脚本引用正在加载?启动firebug或fiddler,看看是否有404

下面是我在coderun.com上的作品

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>jQueryUIV172Application</title>
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/themes/ui-lightness/jquery-ui.css"
type="text/css" media="all" />

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js"></script>

<script src="index.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() { 
$("#dialog").dialog(); 
})
</script>
</head>
<body>
<div id="dialog">
Hello
</div>
</body>
</html>

JQUERYUIV172应用程序
$(文档).ready(函数(){
$(“#dialog”).dialog();
})
你好

您还可以尝试加载对JS文件的引用,如下所示:

<script src="<%=Url.Content("~/Scripts/jquery-1.4.2.js")%>" type="text/javascript"></script> 
<%= Html.Telerik().ScriptRegistrar().DefaultGroup(group =>
                    group.Add("~/Scripts/jquery-1.4.2.min.js")
                    .Add("~/Scripts/jquery-ui-1.8.1.custom.min.js")
                    .Add("~/Scripts/jquery.validate.js")
                    .Add("~/Scripts/Common.js")
            )
%>

我发现了问题。我一直在使用“Telerik Extension for ASP.NET MVC”,它有一个名为ScriptRegistrar的函数(这是一个词吗?),我不得不这样使用它:

<script src="<%=Url.Content("~/Scripts/jquery-1.4.2.js")%>" type="text/javascript"></script> 
<%= Html.Telerik().ScriptRegistrar().DefaultGroup(group =>
                    group.Add("~/Scripts/jquery-1.4.2.min.js")
                    .Add("~/Scripts/jquery-ui-1.8.1.custom.min.js")
                    .Add("~/Scripts/jquery.validate.js")
                    .Add("~/Scripts/Common.js")
            )
%>

group.Add(“~/Scripts/jquery-1.4.2.min.js”)
.Add(“~/Scripts/jquery-ui-1.8.1.custom.min.js”)
.Add(“~/Scripts/jquery.validate.js”)
.Add(“~/Scripts/Common.js”)
)
%>

非常感谢所有帮助我解决这个问题的人

似乎您必须通过Telerik提供的这个神奇的“注册器”方法注册所有脚本文件,否则页面中的其他脚本将无法工作。

您正在运行哪个版本的jQueryUI?当我开始我的项目时,版本似乎是1.8,Visual Studio显示jquery-ui.js已加载。最好启动Firefox和Firebug,用F5刷新页面,并检查“Net”选项卡下的所有内容是否加载良好(黑色)或是否有任何错误(红色)。