Solved

web.config and javascript libraries

Posted on 2014-09-11
6
265 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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to prevent website from publishing with errors 9 44
asp day pilot 3 18
performance issue in asp web 5 28
VB.net Move a class from Solution Items to a project 2 22
In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

813 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

17 Experts available now in Live!

Get 1:1 Help Now