如何为asp.net应用程序的根路径 [英] How to set the root path for asp.net application

查看:133
本文介绍了如何为asp.net应用程序的根路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含摆在多个文件夹页的asp.net应用程序。我有我的.js文件也于一体的JS文件夹,我加入了他们的负责人引用母版页这样的:

I have an asp.net application containing pages that lie in multiple folder. I have my .js files also in one "JS" folder and I have added their reference in head of master page like:

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

现在,当我主页上,该脚本加载罚款。但是,当我一些其他的页面是present在另一个文件夹(物理为例)上,该路径被追加,所以我得到的错误:

Now when I am on home page, the script loads fine. But when I am on some other page that is present in another folder(Physics for example), the path gets appended and hence I get the error:

无法加载资源:服务器与404状态响应
  (未找到)

Failed to load resource: the server responded with a status of 404 (Not Found)

类似的事情正在发生的事情对我的形象的路径和&LT; A&GT; 标签也。

Similar thing is happening for my image paths and <a> tags also.

现在我想给相对于根路径是这样的路径:

Now I want to give paths with respect to root path something like:

~/JS/VerticalMenu.js

但这个不带我去我的应用程序的根目录。我是否需要设置,其中应引起?如果是的话那么在何处以及如何?

But this ~ is not taking me to the root of my application. Do I need to set where ~ should lead to? And if yes then where and how??

推荐答案

试试这个:

<script type="text/javascript" 
    src="<%=Page.ResolveUrl("~/JS/VerticalMenu.js")%>"></script>

这篇关于如何为asp.net应用程序的根路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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