?
Solved

web.config and javascript libraries

Posted on 2014-09-11
6
Medium Priority
?
271 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 53

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 53

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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 53

Accepted Solution

by:
Scott Fell,  EE MVE earned 2000 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
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 …
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

752 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