Solved

web.config and javascript libraries

Posted on 2014-09-11
6
263 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
Comment Utility
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
Comment Utility
can you expand on what an include is?
0
 
LVL 52

Expert Comment

by:Scott Fell, EE MVE
Comment Utility
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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 1

Author Comment

by:HLRosenberger
Comment Utility
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
Comment Utility
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
Comment Utility
thanks
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

I have helped a lot of people on EE with their coding sources and have enjoyed near about every minute of it. Sometimes it can get a little tedious but it is always a challenge and the one thing that I always say is:  The Exchange of information …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

743 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now