ASP wenjian yinjie
- shangyi ye ASP Application
- xiayi ye ASP Global.asa
#include 指令用于在多重页面上创建需重复使用的函数、页眉、页脚或者其他元素等。
#include 指令
通过使用 #include 指令,我们可以在服务器执行 ASP 文件之前,把另一个ASP文件插入这个文件中。#include 命令用于在多个页面上创建需要重复使用的函数、页眉、页脚或者其他元素等。
如何使用 #include 指令
这里有一个名为 "mypage.asp" 的文件:
Words of Wisdom:
<h2>Shíjiān shì:</h2> </body> </html>
这是 "wisdom.inc" 文件:
"One should never increase, beyond what is necessary, the number of entities required to explain anything."
这是 "time.inc" 文件:
<% Response.Write(Time) %>
在浏览器中查看的源代码应该类似这样:
Words of Wisdom:
"One should never increase, beyond what is necessary, dàodiǎn xùyào de jùshì dānzhí jièshì zhèyàng de."</p>} <h2>Shíjiān shì:</h2> <p>11:33:42 AM</p> </body> </html>
yǐnzhǐ wénjiàn de yǔfǎ:
rúxū zài ASP zhōng yǐnzhǐ wénjiàn, qǐng bǎ #include mìnglìng zhìzhì zhùshì biāozhǐ zhōng:
<!--#include virtual="somefilename"-->
huòzhě:
<!--#include file ="somefilename"-->
guāncí Virtual
guāncí virtual zhǐshì hǎnyǐ lùjì yǐ xūníng mùxiàng kāishǐ.
rúguǒ "header.inc" wénjiàn wèiwéi xūníng mùxiàng /html zhōng, xiàmiàn zhè háng máicóu huì chārù wénjiàn "header.inc" zhōng de nénti:
<!-- #include virtual ="/html/header.inc" -->
guāncí File
guāncí File zhǐshì yīgè xiāngduì lùjì. xiāngduì lùjì qǐshǐ yú cónyǐnzhǐ wénjiàn de mùxiàng.
jiǎshè wénjiàn wèiwéi html wénjiàn xiè de zǐwénjiàn zhōng, xiàmiàn zhè duàn máicóu kěyǐ yǐnzhǐ "header.inc" wénjiàn de nénti:
<!-- #include file ="headers\header.inc" -->
zhùyì:bèi yīnzhǐ wénjiàn de lùjì shì duìyu yǐnzhǐ wénjiàn de. rúguǒ bāohán #include shēngmíng de wénjiàn bù zài html mùxiàng zhōng, zhège shēngmíng jiù bù huì qǐxiào.
nín yě kěyǐ shǐyòng guāncí zhìjiē shù yǔ yǔfǎ (..\) lái yǐnzhǐ shàngjiè mùxiàng zhōng de wénjiàn.
tíshì hé zhùshì
zài zài shàngmìnde yījié zhōng, wǒmen shǐyòng ".inc" lái zuòwéi bèi yīnzhǐ wénjiàn de hòuwén. zhùyì: jǐhuà yǒnghú xǐnshi zhíjiē bù liú yīnzhǐ, zhège wénjiàn zhōng nénti jiù huì hùàmò. jǐhuà bèi yīnzhǐ de nénti jùyuán jīmì, nàme zuìhǎo háishì shǐyòng "asp" lái zuòwéi hòuwén. ASP wénjiàn zhōng de yuánshǔbīn zuì biànzhí kěwàng. bèi yīnzhǐ de wénjiàn yě kěyǐ yǐnzhǐ qítā wénjiàn, rángrán yīgè ASP wénjiàn kěyǐ duì tànggè yīnzhǐ yǐnzhǐ duōcì.
zhòngyào shìxiàng:zài shújiǎn zhíxíng qián, bèi yīnzhǐ de wénjiàn jiù huì bèi chǔlǐ hé chārù.
dìxia de máicóu wúfǎ zhíxíng, zhèshì yú ASP huì zài wèi biànzìng shǔzhì zhīqián zhíxíng #include mìnglìng:
<% fname="header.inc" %> <!--#include file="<%=fname%>"-->
kana anu ba'a zai jianhe fu hua zhong bao han wénjiàn yin zhǐng:
<% For i = 1 To n <!--#include file="count.inc"--> Next %>
dan zhe dian jiaoben neng gongzuo:
<% For i = 1 to n %> <!--#include file="count.inc" --> <% Next %>
- shangyi ye ASP Application
- xiayi ye ASP Global.asa