How to get JqueryUI to work with ASP.Net Master Pages and multiple paths?

泄露秘密 提交于 2019-12-10 23:14:43

问题


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>

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.


回答1:


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>

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



来源:https://stackoverflow.com/questions/8417641/how-to-get-jqueryui-to-work-with-asp-net-master-pages-and-multiple-paths

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!