Usercontrol access javascript from a Content's Page's Master Page

Posted by Coda on Stack Overflow See other posts from Stack Overflow or by Coda
Published on 2009-03-11T00:07:08Z Indexed on 2010/05/20 20:00 UTC
Read the original article Hit count: 210

Hello all I have a problem. I have a masterpage that all of my Content pages inherit from. Within this masterpage I have a script tag pointing to the javascript file folder "~/Scripts/validation.js"

On my content pages I use different usercontrols that require the use of many of the functions within the validation.js file however if I dont put the tag and the javascript functions within a contentholder on the contentpage the usercontrols do not see these functions and I get errors like "OnNameValidation" is not defined.

Of course I can copy the javscript code into all of the pages but that's 30+ pages and a maintenance nightmare if I find a bug in one of the javscript functions.

So the question (if you haven't already figured out from my long dissertation) is how can I declare the script tag with the path to the validation.js file so that contentpages and their usercontrols etc. can access the functions/code.

Thanks in advance.

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about master-pages