在我的ASP中找不到Javascript.网络应用程序

Javascript not found in my ASP.Net Application

本文关键字:Javascript 网络 应用程序 找不到 我的 ASP      更新时间:2023-09-26

我在我的javascript的位置有问题,位置是正确的,但是当我在我的visual web developer 2010 express中运行它时,找不到位置,我不知道原因…

这里是我的javascript的位置:

<script src="Style/javascript/jquery-1.7.1.js" type="text/javascript"></script>

错误如下:

**Server Error in '/Maitenance' Application.**
**The resource cannot be found.**
**Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable.  Please review the following URL and make sure that it is spelled correctly.** 
**Requested URL: /Maitenance/Maintenance/Style/javascript/jquery-1.7.1.js**

使用这个…会成功的

<script src="<%=Page.ResolveUrl("~")%>Style/javascript/jquery-1.7.1.js" type="text/javascript"</script>

我猜你正在使用一个母版页和你的。aspx页放在另一个目录。包含在母版页中的文件路径是相对于.aspx文件的。当您的页面与母版页位于同一目录时,它可以正常工作。

你可以使用ResolveUrl:

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

或者您可以将脚本包含在母版页后面的代码中:

ClientScript.RegisterClientScriptInclude("jquery", ResolveClientUrl("~/js/jquery.js"));