I am new to asp.net. I have a question, How do I make javascript file work on any page that inherit from the master page? Because i put <link type="text/javascript" href="scripts/JScript.js" /> in the masterpage and it didn't seem to work?
2 Answers
Here is the problem: Instead of
<link type="text/javascript" href="scripts/JScript.js" />
use following:
<script type="text/javascript" src="scripts/JScript.js"></script>
let me know if it does not wok.
1 Comment
Lukasz M
You are right,
link instead of script is at last one of the issues. I haven't noticed this. Nice catch:).Try to do it like this:
<link type="text/javascript" href="/scripts/JScript.js" />
Update
This seems not to work in your case. Take a look at the second scenario described in this website:
Calling JavaScript from ASP.NET Master Page and Content Pages - Part II
This explains how to do it.
4 Comments
Keenlearner
I forget to mention that I'm trying to run it on server side
Lukasz M
You mean calling java script on server side or just referring to some script to make it run i.e. after page is loaded? Could you explain this?
Keenlearner
Call the javascript on server side sorry
Lukasz M
Take a look at my updated answer and at a link I mentioned there. The second scenario seems to be describing how to make it work in your case.