Use a Script Library
Published 1/25/01
Why?
If you have something that you do often, on many pages (like open a database connection, display changing content on your pages etc.) then you should use a script library.
Eg. Let us say that your using the XML News thing from this article and you want to show this on a few pages. Ok, you'll use an include wherever you want to use it. Lets say that you also have a DB connection that you use frequently and you've added some tweaks to the XML News code so you can change what it displays. Now you may want to consider a script library.
How?
It's very simple, just create an ASP/ASP.NET page with a bunch of methods, like -
<% Sub writemessage(message as String) Response.Write(message & " Printed by your Script Library." End Sub
Sub openDB() 'Open DB End Sub
Sub QueryDB(qstring as String) 'Check for Connection 'Run Query End Sub %> |
Then all you have to do is include it at the top of your ASP/ASP.NET file.
<!-- #include file="/scriptlib.asp" --> |