Question

I am having a problem in the location of my javascript, the location is right, but when I run it in my visual web developer 2010 express, the location can not be found, I don't know the reason why...

here is the location of my javascript:

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

here is the error:

**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**
Was it helpful?

Solution

Use this... It will work

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

OTHER TIPS

I guess you are using a master page and your .aspx page is put in another directory. The file path you included in master page is relative to the .aspx file. It works OK when your page in the same directory with the master page.

You can include your js file using ResolveUrl:

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

or you can include your script in the code behind of master page:

ClientScript.RegisterClientScriptInclude("jquery", ResolveClientUrl("~/js/jquery.js"));
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top