Solved

web.config and javascript libraries

Posted on 2014-09-11
6
266 Views
Last Modified: 2014-09-12
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?
0
Comment
Question by:HLRosenberger
  • 3
  • 3
6 Comments
 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
ID: 40317173
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.
0
 
LVL 1

Author Comment

by:HLRosenberger
ID: 40317222
can you expand on what an include is?
0
 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
ID: 40317425
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
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
LVL 1

Author Comment

by:HLRosenberger
ID: 40317732
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?
0
 
LVL 52

Accepted Solution

by:
Scott Fell,  EE MVE earned 500 total points
ID: 40317755
You have to load your js files on every page.  If you want a global way to do this, use an include file where there is one file of just your js files.  Then if you need to shuffle them around, take something out or add, you just update the one include file.    

You are correct that the script, <script language="javascript" type="text/javascript" src="/Scripts/TNCP.js"></script> already is an include file of sorts.  One is client side and the other is serverside.  

If you build your template using include files like this, it will make your life very easy.  I use one for css, js, header, nav and footer since those files are always the same on every page.  Then just change the body of each individual page.    This method is very similar to how wordpress and other cms's work.
0
 
LVL 1

Author Closing Comment

by:HLRosenberger
ID: 40319496
thanks
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question