views:

56

answers:

1

I am working on a asp.net mvc c# jquery application. For some reason when I drag a file from the solution explorer on to my code page I no longer get the path to the file. All I get is

<a href="../../">../../</a>

If I start with a new MVC project and drag a file say the jquery file Visual Studio gives me this,

<script src="../../Scripts/jquery-1.3.2.min.js" type="text/javascript"></script>

but in my existing project when I drag the same file I get this,

<a href="../../">../../</a>

Any idea why?

+1  A: 

Your links to files should be managed with the Routing system in asp.net MVC. You cannot link to files in the same way you would in a web forms solution.

For example.

If you want to route to the Home Controller and Index View then you can use the code.

<a href="<%= Url.Action("Index", "Home") %>">Link Text</a>

There are some additional html Helpers though available to you in asp.net MVC that would output the whole anchor tag for you.

<%= Html.ActionLink("Home", "Index", "Home")%>

More documentation about the subject can be found at http://www.asp.net/mvc/learn/

Webmonger
Thanks for the reply, but I was talking about the visual studio interface not mvc coding. When I drag a javascript file from the folder onto my master page VS should give me the link to the file but it does not. In a new project it works fine, but in my current project it stopped working.
Tony Borf
Sounds like an odd issue sorry I can't help with that. Have you tried comparing the working and non working solution files to make sure it's nothing obvious in there causing the problem?
Webmonger