Link to home
Start Free TrialLog in
Avatar of HLRosenberger
HLRosenbergerFlag for United States of America

asked on

web.config and javascript libraries

I have a set of javascript functions.   I have this statement in each page:

<script language="javascript" type="text/javascript" src="/Scripts/TNCP.js"></script>

Is there a way to do this in the web.config so that I don't have to add it to each page?
Avatar of Scott Fell
Scott Fell
Flag of United States of America image

I would add it as in a include.  Make  an include page that just contains your js files to be used on every page and place them there.  It is a great way to make a template in asp.
Avatar of HLRosenberger

ASKER

can you expand on what an include is?
An include file can be any text, html, asp file.  

Your page would look like below with only your js files.  I would do the same with css files, header and footer.

/INCLUDES/JS.ASP
<script src="/Scripts/TNCP.js"></script> 
<script src="/Scripts/foo.js"></script> 
<script src="/Scripts/bar.js"></script> 

Open in new window

INDEX.ASP
<!DOCTYPE html>
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<html>
<!-- #include virtual file ="/includes/js.asp" --> 
<head>
  <meta charset="utf-8">
  <title>padas</title>
</head>
<body>

</body>
</html>

Open in new window


<!DOCTYPE html>
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<html>
<!-- #include virtual file ="/includes/css.asp" --> 
<!-- #include virtual file ="/includes/js.asp" --> 
<head>
  <meta charset="utf-8">
  <title>padas</title>
</head>
<body>
<!-- #include virtual file ="/includes/header.asp" --> 
<!-- #include virtual file ="/includes/footer.asp" --> 
</body>
</html>

Open in new window


http://msdn.microsoft.com/en-us/library/ms524876(v=vs.90).aspx
bear with me, but I'm not quite following.   This statement in my page:

<script language="javascript" type="text/javascript" src="/Scripts/TNCP.js"></script>

tells the system to pull in the javascript in the TNCP.JS file and make it available to the page, correct?  So that's sort of like an include.  I'm looking for a way to do this globally, for the whole project, and not page by page.   I want my library of javascript functions available on every page.  Does that make sense?

Are you saying I can create one include file that has an include directive that will pull in the TNCP.JS file for all pages?
ASKER CERTIFIED SOLUTION
Avatar of Scott Fell
Scott Fell
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
thanks