Recommended: Cache compatibility design for WEB applications After passing the proxy, since an intermediate layer is added between the client and the service, the server cannot directly obtain the client's IP, and the server-side application cannot directly return to the client through the forwarding address. However, in the HTTP header information of forwarding requests, HTTP_X is added
In order to avoid maintenance difficulties caused by the misunderstanding of ASP program TML code, this article introduces a method to use templates to separate programs and pages to make programming easier.
When using ASP to create a site, there is often a situation where the program code and HTML code are mixed in an ASP file. There are many disadvantages to doing this
1. Not to mention that when programming, you must design and arrange the page layout, which will cause the code to be confused and difficult to understand and irregular;
2. When you need to change the appearance of the page, you not only need to change the HTML part, but also need to change the ASP code, which is not easy to maintain.
So, how can we avoid these troubles?
The answer is to use a template file to separate the ASP code and HTML pages, and all problems will be solved. Using templates has the following benefits:
1. The appearance of the entire site can be replaced in a very short time;
2. Enable programmers to abstract programming without having to touch HTML code;
3. The previous template can be reused.
Programs that have used PHP will know that PHP has a template program (FastTemplate). The current problem is how to implement similar functions in ASP.
Microsoft's ASP comes with two scripts: VBScript and JScript. They all come with a regular expression object (RegExp). Using string objects and RegExp objects, you can easily implement template functions. Mu Feng used this to write a Template.JScript.INC file, and the content of this file is attached to the end of the article. A competent reader can improve according to their needs.
Here is a description of how to use it. Since this file is written in JScript (of course it is easy to convert it to VBScript), the default scripting language should be set to JScript, that is, the first line of the ASP program should be: %@Language=JScript%, and then the template program file is included: !#includefile=Template.JScript.INC.
Let me first introduce the use of the Template class:
1. Create a Template object: Template(Path)
Parameters: Path (string type) HTML template file storage path.
Use the new operator to create a Template object.
Share: Basic ASP Tutorial: Learning the Application of Subprograms in ASP In ASP, you can call your own program through VBScript and other ways. Example: Calling a subroutine using VBScript How to call a subroutine written in VBScript from ASP. The following is the quoted content
4 pages in total Previous page 1234Next page