Let's take a look at ASP-style
====================
You can add the content of an ASP page to another ASP page before the server executes it by using the # include command.
# The include command is used to create functions, headers, footers, or parts to be reused by multiple pages.
How to use it?
This is "mypage. asp"
This is the "wisdom. Inc" file.
"One shoshould never increase, beyond what is necessary,
The number of entities required to explain anything ."
This is the "time. Inc" file.
<%
Response. Write (time)
%>
If you view the source code in the browser, you will see the following:
Syntax
<! -- # Include virtual = "somefilename" -->
Here, virtual indicates that the address is from a virtual path. for example, a file named header. inc files exist in a virtual directory named/html. The following command inserts the header. contents of INC
<! -- # Include virtual = "/html/header. Inc" -->
<! -- # Include file = "somefilename" -->
The file indicates that the path is a relative path. if there is an object in the HTML folder and the header. the INC file exists in HTML \ headers, so the following code inserts the header. inc file content
<! -- # Include file = "headers \ header. Inc" -->
The ASP. NET page dynamically contains HTML files and client segment script files.
======================================
Because ASP. NET applications need to be compiled and run before they are sent to the client, you cannot use variables to replace the file name when you include files on the server (for example: <! -- # IncludePathtype=Filename-> "). However, you can useResponseOrStreamreaderObject To write the include file into the HTML stream.
Example:
<%@ Page Language="vb" AutoEventWireup="false"%>
Insert the content of the specified file to the ASP. NET page, including the web pages (. aspx file), user control files (. ASCs file), and Global. asax file.
======================================
Syntax, the same as ASP-style include.
<! -- # Include file | virtual = "FILENAME" -->
Remarks
The value assigned to the file or virtual attribute must be enclosed in double quotation marks (""). the encoded file will be processed before any dynamic code is executed. include files can be used to include static text (such as common page headers or company addresses), server-side code, controls ), or the developer wants to insert the HTML Tag block into other pages.
Although you can also use this # include method to reuse code, in ASP. net is usually better than Web user controls. because user control provides an object-oriented programming model and is more powerful than include on the server side.
# The include tag must be enclosed by the annotation boundary of HTML or XML to avoid being interpreted as literal text.
Example:
References:
How to dynamically include files in ASP. NET
Http://support.microsoft.com/kb/306575
Server-side include Directive syntax
Http://msdn.microsoft.com/en-us/library/3207d0e3.aspx
ASP including files
Http://www.w3schools.com/asp/asp_incfiles.asp