Master Pages and JavaScript

G

Guest

Hi all

I have a MasterPage and a Content Page. I want to raise a client side event
for a control on my Content page

When I place the javascript code in master page file it works fine. But when
I place the code in the some js file and refer it in the master page it
doesnt work..

Please Suggest

Regards
 
S

Sean Chambers

Hello,

Ya know, I messed with this for about a week on my current personal
business project, after the 5 day mark I just dumped the js in the
master page for the time being as I couldn't waste anymore valuable
time on it and needed to press on

I am very interested in someone's response to this, as I will need to
utilize the response as well

Thanks

Sean
 
R

Rob Roberts

Sekhar said:
Hi all

I have a MasterPage and a Content Page. I want to raise a client side
event
for a control on my Content page

When I place the javascript code in master page file it works fine. But
when
I place the code in the some js file and refer it in the master page it
doesnt work..

Without more details other than just "it doesn't work" it's pretty hard to
guess, but it sounds like it might be a path problem. Maybe it's not
finding the js file?

--Rob Roberts
 
S

Sean Chambers

Just off the top of my head, make sure your <head> tag has a
runat="server" attribute.

then when you reference the js file, you can use the
~/path/to/javascripts.js

I thought I tried this, don't remember though
 
G

Guest

Hello

I figured it out. Try using RegisterScriptInclude method

Page.ClientScript.RegisterScriptInclude

It works
 

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

Top