Master Pages and JavaScript

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
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
 
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
 
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
 
Hello

I figured it out. Try using RegisterScriptInclude method

Page.ClientScript.RegisterScriptInclude

It works
 
Back
Top