How to include a js file globally in asp.net

G

green_tea

Hi there,


I'd like to know how to include a js file globally in asp.net so all my
pages can access js functions in this file. (Only include it once and
not include
this file one by one to all my pages.)

Thanks for your help.

Green
 
K

KJ

Hello there,

If you're using .NET 2.0, you can include the js file in a master page.
If using 1.x, you will have to include it in each page via the <script
language='javascript' src="myjs.js"></script> tagging.

Alternatively, you can place the entire site as the src of a
single-framed frameset, and include the script tags in the frameset
page; then, when you call your js methods, always call
top.methodname(), since the frameset page is the top.
 
G

green_tea

Thanks a lot KJ.

I guess I am going to include it in the frameset as I am use frames.

Thanks for you help.

Green.
 
L

Laurent Bugnion

Hi,

Thanks a lot KJ.

I guess I am going to include it in the frameset as I am use frames.

Thanks for you help.

Green.

Including a script file in the frameset is often a bad idea. Remember
that each frame and the frameset itself are separate windows, so if the
script runs in the frameset, you must use inter-window communication,
which complicates the whole process.

In the contrary, masterpages and their content run, eventually, in one
single window, so you won't have that issue.

HTH,
Laurent
 
M

Mark Rae

I guess I am going to include it in the frameset as I am use frames.

I concur with what Laurent said, and really advise you not to do that.

Use MasterPages instead.
 
G

green_tea

Thanks Mark and Laurent and everyone who helped me.

I am new to ASP.NET, it seems I have a lot to learn.

Green.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,781
Messages
2,569,615
Members
45,296
Latest member
HeikeHolli

Latest Threads

Top