javascript 的 asp.net webform 路由问题

发布于 2024-10-02 07:35:10 字数 788 浏览 1 评论 0原文

我正在使用 asp.net 4 路由,到目前为止我很享受它。我的 javascript 文件只有一个问题。 我正在使用母版页添加我的 css 和 javascript。 css 工作正常,但 javascript 却不行。

我的母版页中的链接如下所示

  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="~/_styles/css/core.css" rel="stylesheet" type="text/css" />

<link href="~/_styles/css/facebox.css" rel="stylesheet" type="text/css" />
<script src="~/_styles/js/jquery-1.3.2.min.js" type="text/javascript"></script>
<script src="~/_styles/js/jquery.validate.js" type="text/javascript"></script>

<script src="~/_styles/js/facebox.js" type="text/javascript"></script>
<script src="~/_styles/js/corejs.js" type="text/javascript"></script>

为什么我的 css 加载正确,但 js 加载不正确?

I am using asp.net 4 routing and im enjoying it so far. I have one problem only with my javascript files.
I am using a masterpage to add my css and javascript. The css is working fine however the javascript is not.

My links from my masterpage look like this

  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link href="~/_styles/css/core.css" rel="stylesheet" type="text/css" />

<link href="~/_styles/css/facebox.css" rel="stylesheet" type="text/css" />
<script src="~/_styles/js/jquery-1.3.2.min.js" type="text/javascript"></script>
<script src="~/_styles/js/jquery.validate.js" type="text/javascript"></script>

<script src="~/_styles/js/facebox.js" type="text/javascript"></script>
<script src="~/_styles/js/corejs.js" type="text/javascript"></script>

Why does my css load correctly but the js doesnt?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

七月上 2024-10-09 07:35:10

这个问题有点老了..但是当您从不同的目录结构移动时,我使用 ASP.NET 4.0 路由并引用不同的 js 文件或样式表时遇到了同样的情况..我用来解决的是:

<script src='<%=ResolveClientUrl("~/js/fancybox/jquery.fancybox-1.3.4.js")%>' type="text/javascript"></script>

所以关键是使用 ResolveClientUrl

希望这对将来的人们有帮助。

This is question is bit old..but i faced same situation using ASP.NET 4.0 routing and referencing different js file or stylesheet when you move from different directory structure.. what i used to resolve is:

<script src='<%=ResolveClientUrl("~/js/fancybox/jquery.fancybox-1.3.4.js")%>' type="text/javascript"></script>

So key was using ResolveClientUrl

Hope this helps people in future.

老娘不死你永远是小三 2024-10-09 07:35:10

请检查并确保添加脚本链接时。您只需键入

Please check and make sure when you adding the link for your script.You just type the
<script src=" and Ctrl+Space then choose your file.If you can't find your project path,just try it to get in that path.Sometime,the file will not in that path when you may be copy & paste that file to your project path(not from your VS Project explorer).

悲欢浪云 2024-10-09 07:35:10

您可以简单地使用 _styles/js 和 _styles/css。

you can use simply _styles/js and _styles/css.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文