0

I have one MVC view page in which I show different links and I am using ThickBox to show a different page when ever one of these links is clicked. In these pages, I am using jQuery functions to do some changes, but I am not able to resolve the jquery file path on the view pages. I need to give absolute path something like "http://test.com/js/jquery.js". But is there any way to make it relative?

I also tried getting the host url and using <%=%> and <%# %> but none is working.

Any help?

Thanks Ashwani

3 Answers 3

2

This is when you run the MVC app from visual studio? If so set you're MVC application's virtual path to start at "/" instead of the default that is probably your project name.

This can be done by right-clicking on the MVC project in the solution explorer > Click Properties > Click the Web tab > Type "/" (without the quotes) in the Virtual path textbox. Then use Andrew Florko's suggestion of leading it with a slash <script src="/js/jquery.js"> </script>

alt text http://img707.imageshack.us/img707/3765/virtualpath.jpg

Sign up to request clarification or add additional context in comments.

Comments

0

What about trying something like:

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

Comments

0

Maybe you should try

<script src="/js/jquery.js" ...

instead of intellisence-generated path with ".."

<script src="../../js/jquery.js" ...

2 Comments

It's strange. Please, run FireBug and introspect your html layout. Does it show content of js file?
No, it is not showing any js content, I have to give absolute path to run the js code

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.