如何使JqueryUI与ASP.Net母版页和多个路径一起使用? [英] How to get JqueryUI to work with ASP.Net Master Pages and multiple paths?

查看:87
本文介绍了如何使JqueryUI与ASP.Net母版页和多个路径一起使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的ASP.Net 4.0网站,该网站使用我想包含JqueryUI的母版页. 头看起来像这样.

I have a simple ASP.Net 4.0 website that uses a master page that I would like to include JqueryUI. The Head looks like this.

<head runat="server">
<title></title>
<link href="~/css/Main.css" rel="stylesheet" type="text/css" />
<script src="js/jquery-1.6.2.min.js" type="text/javascript"></script>
<script src="js/jquery-ui-1.8.16.custom/js/jquery-ui-1.8.16.custom.min.js" type="text/javascript"></script>
<link href="js/jquery-ui-1.8.16.custom/css/cupertino/jquery-ui-1.8.16.custom.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
         $(function () {
             $("#accordion").accordion();
         });
</script>
 <asp:ContentPlaceHolder ID="HeadContent" runat="server">

</asp:ContentPlaceHolder>

对于从母版页继承的内容页,只要它位于同一目录中,一切都可以正常使用.因此,如果内容页面是/Home.aspx很好,但是如果内容目录是/Sales/Home.aspx,则样式永远不会应用于在母版页中定义的手风琴.

Everything works fine for content pages that inherit from the Master Page as long as it is in the same directory. So if the content page is /Home.aspx alls good, but if it is /Sales/Home.aspx the the styles are never applied to the accordion that is desfined n the Master Page.

推荐答案

通过使用..."js/jquery-ui-1.8.16.custom/..您正好重定向到JS文件夹(是一个单词吗?)到当前页面的文件夹中.如果位于Sales/...中,它正在寻找Sales/中的JS文件夹,但可能不存在.您可以使用指向该文件夹的绝对链接来防止这种情况根:

By using ... "js/jquery-ui-1.8.16.custom/ .. you're redirecting to the JS folder, relativily (is that a word?) to the folder of the current page. If that's in Sales/..., it's looking for the JS-folder in Sales/ but it probably isn't there. You can prevent this by using an absolute link to the root:

<script src="/js/jquery-1.6.2.min.js" type="text/javascript"></script>

这样,它将在网站的根目录中查找JS文件夹.

This way it will look for the JS folder in the root of the site.

这篇关于如何使JqueryUI与ASP.Net母版页和多个路径一起使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆