Using execute in ASP to dynamically include files

Source: Internet
Author: User

Abstract: This article describes how to dynamically include ASP files in ASP and Make ASP classes instantiated.

In ASP, include file/virtual is the priority scriptCodeTherefore, you cannot use include to dynamically include ASP files. We can use the Execute function to dynamically execute the required code.

Method:
Execute (ASP code)

Example: (vbcrlf is a line break)Copy codeThe Code is as follows: Execute ("class clsabc" & vbcrlf & "public function output" & vbcrlf & "response. write 123 "& vbcrlf &" end function "& vbcrlf &" End Class ")Copy codeThe Code is as follows: dim objabc
Set objabc = new clsabc
Objabc. Output
Set objabc = nothing

ASP code can be read from a file or database before execution. Note that the executed code should not contain <% and %>
Be sure not to be confused with server. Execute. The server. Execute parameter is an ASP virtual path, and using this function not only does not dynamically declare the class, or even cannotProgramVariable value.
Example:
Main. asp Copy codeThe Code is as follows: dim strabc, objabc
Strabc = "test"
Server. Execute ("sub. asp ")
Response. Write strabc
Set objabc = new clsabc
Objabc. Output
Set objabc = nothing

Sub. asp Copy codeThe Code is as follows: strabc = "execute"
Class clsabc
Public Function output
Response. Write "class"
End Function
End Class

After main. asp is executed, only test is output, while objabc cannot be instantiated.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.