Include|include I spoke to a friend of mine yesterday about the path using include, so I remember talking about it before, and now I want to write it back here for your reference, hoping to have more friends to discuss the issue.
============================
Include in the use of Web page production is simple and flexible, it can not only reduce the complexity of the page, but also make the management more orderly and effective, many friends are asking whether the dynamic use of include? Here I stress,<!--#include file= "<%fileName%>"--> is absolutely unworkable, if you use
<%if xxx = "yyy" then%>
<!--#include file= "file1.asp"-->
<%else%>
<!--#include file= "file2.asp"-->
<%end if%>
This will virtually download unnecessary files, affecting the speed of loading the Web page. How to solve this problem? What I know is the following methods:
<%
1)
If xxx = "yyy" Then
Server.Execute ("file1.asp")
Else
Server.Execute ("file2.asp")
End If
2)
If xxx = "yyy" Then
Server.Transfer ("file1.asp")
Else
Server.Transfer ("file2.asp")
End If
3)
if xxx = "yyy" Then
filespec = "File2.asp"
Else
filespec = "File2.asp"
End If
filespec = Server.MapPath (filespec)
SCR = "Scripting.FileSystemObject"
Set fs = Server.CreateObject (SCR)
Set F = Fs.opentextfile (filespec)
Content = F.readall
Set F = Nothing
Set fs = Nothing
Response.Write (content)
%>
What I want to explain is that if you use the above methods to implement the include feature, you have to be aware of the place.
We can file= the <!--#include "file.asp"--> Included in the Web page file.asp as an integral part of the Web page that contains the file.asp, only to save what was originally part of the Web page in another file, so that they would have been a Web page, so that the included page file.asp inherits all the parameters of the page containing the file.asp Number set, include session However, other methods are not the case, in the HTML syntax part can be shared with the main Web page, the ASP part is independent, the special session in general can not be passed from the main page to be included in the page file.asp, this is important, use to pay attention to.