3

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?

0

2 Answers 2

3

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.

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

1 Comment

You are right, link instead of script is at last one of the issues. I haven't noticed this. Nice catch:).
0

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

I forget to mention that I'm trying to run it on server side
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?
Call the javascript on server side sorry
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.

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.