Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Web
Expertise: Beginner
Nov 3, 1999

Share Script Functions

In ASP pages, you can share script functions or libraries using the #INCLUDE directive. This feature allows you to share subroutines and functions across multiple pages. Instead of repeating similar (or rather same) script functions in most of your asp pages, you can club them into a single file and later on include that file so that its subroutine and functions are available.

For example, you can use following line to include subroutines and functions of file SampleServerFunctions.inc

 
<!--#INCLUDE FILE="SampleServerFunctions.inc" -->
Make sure that the #INCLUDE line comes before any calls to subroutines or functions in the file.

In client script, you can include references to other files in the <SCRIPT> block. Use the SRC attribute to specify the name of a file that contains script you want to include. The SRC attribute of the <SCRIPT> tag lets you specify a file that contains the script source, rather than embedding the complete script source in the HTML. This attribute is especially useful for sharing functions among many different pages. For example, the following <SCRIPT> block includes a reference to a page containing common client side routines.

 
<SCRIPT SRC="SampleClientFunctions.inc"></SCRIPT>
After you have included a reference to a file in this way, you can call script on the page as if it were in the current page. Using this feature you get more maintainable code which also helps in increasing the productivity by reducing the development time.
Deepak Pant
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date