📄 asp_quickref.asp
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en-US" xml:lang="en-US" xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>ASP Quick Reference</title>
<link rel="shortcut icon" href="../favicon.ico" type="image/x-icon" />
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<meta name="Keywords" content="xml,tutorial,html,dhtml,css,xsl,xhtml,javascript,asp,ado,vbscript,dom,sql,colors,soap,php,authoring,programming,training,learning,beginner's guide,primer,lessons,school,howto,reference,examples,samples,source code,tags,demos,tips,links,FAQ,tag list,forms,frames,color table,w3c,cascading style sheets,active server pages,dynamic html,internet,database,development,Web building,Webmaster,html guide" />
<meta name="Description" content="Free HTML XHTML CSS JavaScript DHTML XML DOM XSL XSLT RSS AJAX ASP ADO PHP SQL tutorials, references, examples for web building." />
<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="cache-control" content="no-cache" />
<link rel="stylesheet" type="text/css" href="../stdtheme.css" />
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "../../https@ssl./default.htm" : "../../www./default.htm");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-3855518-1");
pageTracker._initData();
pageTracker._trackPageview();
</script>
</head>
<body>
<a name="top"></a>
<table cellpadding="0" cellspacing="0" width="100%" bgcolor="#808080">
<tr>
<td width="234" valign="top">
<a href="../default.htm"><img src="../images/w3default80.jpg" border="0" alt="W3Schools" /></a>
</td>
<th valign="middle" align="left" class="right">
<script type="text/javascript"><!--
google_ad_client = "pub-3440800076797949";
/*txtimg*/
google_ad_slot = "5330033957";
google_ad_width = 728;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript" src="../../pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
<noscript>
<a href="../default.asp" target="_blank"><img src="../banners/w6.gif" border="0" alt="W3Schools" /></a>
</noscript>
<br /></th>
</tr>
</table>
<table style="margin-left:1px" width="800px" border="0" cellpadding="0" cellspacing="2">
<tr>
<td width="137" class="content" valign="top"><br />
<a class="left" href="../default.asp" target="_top">
<img src="../images/homeicon.gif" border="0" alt="home" /></a>
<a class="left" href="../default.asp" target="_top">
<b>HOME</b></a>
<br /><br />
<b>ASP Tutorial</b><br />
<a class="left" target="_top" href="default.asp" >ASP HOME</a><br />
<a class="left" target="_top" href="asp_intro.asp" >ASP Introduction</a><br />
<a class="left" target="_top" href="asp_install.asp" >ASP Install</a><br />
<a class="left" target="_top" href="asp_syntax.asp" >ASP Syntax</a><br />
<a class="left" target="_top" href="asp_variables.asp" >ASP Variables</a><br />
<a class="left" target="_top" href="asp_procedures.asp" >ASP Procedures</a><br />
<a class="left" target="_top" href="asp_inputforms.asp" >ASP Forms</a><br />
<a class="left" target="_top" href="asp_cookies.asp" >ASP Cookies</a><br />
<a class="left" target="_top" href="asp_sessions.asp" >ASP Session</a><br />
<a class="left" target="_top" href="asp_applications.asp" >ASP Application</a><br />
<a class="left" target="_top" href="asp_incfiles.asp" >ASP #include</a><br />
<a class="left" target="_top" href="asp_globalasa.asp" >ASP Global.asa</a><br />
<a class="left" target="_top" href="asp_send_email.asp" >ASP Send e-mail</a><br />
<br />
<b>ASP Objects</b>
<br />
<a class="left" target="_top" href="asp_ref_response.asp" >ASP Response</a><br />
<a class="left" target="_top" href="asp_ref_request.asp" >ASP Request</a><br />
<a class="left" target="_top" href="asp_ref_application.asp" >ASP Application</a><br />
<a class="left" target="_top" href="asp_ref_session.asp" >ASP Session</a><br />
<a class="left" target="_top" href="asp_ref_server.asp" >ASP Server</a><br />
<a class="left" target="_top" href="asp_ref_error.asp" >ASP Error</a><br />
<br />
<a class="left" target="_top" href="asp_ref_filesystem.asp" >ASP FileSystem</a><br />
<a class="left" target="_top" href="asp_ref_textstream.asp" >ASP TextStream</a><br />
<a class="left" target="_top" href="asp_ref_drive.asp" >ASP Drive</a><br />
<a class="left" target="_top" href="asp_ref_file.asp" >ASP File</a><br />
<a class="left" target="_top" href="asp_ref_folder.asp" >ASP Folder</a><br />
<a class="left" target="_top" href="asp_ref_dictionary.asp" >ASP Dictionary</a><br />
<a class="left" target="_top" href="asp_ado.asp" >ASP ADO</a><br />
<br />
<b>ASP Components</b><br />
<a class="left" target="_top" href="asp_adrotator.asp" >ASP AdRotator</a><br />
<a class="left" target="_top" href="asp_browser.asp" >ASP BrowserCap</a><br />
<a class="left" target="_top" href="asp_contentlinking.asp" >ASP Content Linking</a><br />
<a class="left" target="_top" href="asp_contentrotator.asp" >ASP Content Rotator</a><br />
<br />
<a class="left" target="_top" href="asp_quickref.asp" style='font-weight:bold;'>ASP Quick Ref</a><br />
<a class="left" target="_top" href="asp_summary.asp" >ASP Summary</a><br />
<br />
<b>Examples/Quiz</b><br />
<a class="left" target="_top" href="asp_examples.asp" >ASP Examples</a><br />
<a class="left" target="_top" href="asp_quiz.asp" >ASP Quiz</a><br />
<a class="left" target="_top" href="asp_exam.asp" >ASP Exam</a><br />
<br />
<b>Selected Reading</b><br />
<a class="left" target="_top" href="../browsers/browsers_stats.asp">Web Statistics</a><br />
<a class="left" target="_top" href="../site/site_glossary.asp">Web Glossary</a><br />
<a class="left" target="_top" href="../hosting/default.asp">Web Hosting</a><br />
<a class="left" target="_top" href="../quality/default.asp">Web Quality</a><br /><br />
<a class="left" target="_top" href="../forum/default.asp">W3Schools Forum</a><br /><br />
<a class="left" target="_top" href="../about/about_helping.asp">Helping W3Schools</a><br /><br />
<script type="text/javascript"><!--
google_ad_client = "pub-3440800076797949";
/*LeftLinkUnit*/
google_ad_slot = "4854527104";
google_ad_width = 120;
google_ad_height = 90;
//-->
</script>
<script type="text/javascript"
src="../../pagead2.googlesyndication.com/pagead/show_ads.js">
</script>
</td>
<td valign="top">
<table style="border: 1px solid gray" width="100%" bgcolor="#FFFFFF" border="0" cellpadding="5" cellspacing="0">
<tr>
<td>
<h1>ASP Quick Reference</h1>
<a href="asp_contentrotator.asp"><img border="0" src="../images/btn_previous.gif" alt="Previous" /></a>
<a href="asp_summary.asp"><img border="0" src="../images/btn_next.gif" width="100" height="20" alt="Next" /></a>
<hr />
<p class="intro">ASP Quick Reference from W3Schools. Print it, and fold it in your pocket.</p>
<hr />
<h3>Basic Syntax</h3>
<p>ASP scripts are surrounded by <% and %>. To write some
output to a browser:</p>
<p><html><br />
<body><br />
<%
response.write("Hello World!")
%><br />
</body><br />
</html></p>
<p>The default language in ASP is VBScript. To use another scripting language,
insert a language specification at the top of the ASP page:</p>
<p><%@ language="javascript" %><br />
<html><br />
<body></p>
<p><%<br />
....<br />
%></p>
<h3>Forms and User Input</h3>
<p>Request.QueryString is used to collect values in a form with method="get".
Information sent from a form with the GET method is visible to everyone (it will
be displayed in the browser's address bar) and has limits on the amount of
information to send.</p>
<p>Request.Form is used to collect values in a form with method="post".
Information sent from a form with the POST method is invisible to others and has
no limits on the amount of information to send.</p>
<h3>ASP Cookies</h3>
<p>A cookie is often used to identify a user. A cookie is a small file that the
server embeds on the user's computer. Each time the same computer requests for a
page with a browser, it will send the cookie too.</p>
<p>The Response.Cookies command is used to create cookies:</p>
<p><%<br />
Response.Cookies("firstname")="Alex"<br />
Response.Cookies("firstname").Expires="May 10,2002"<br />
%></p>
<p><b>Note:</b> The Response.Cookies command must appear BEFORE the <html> tag!</p>
<p>The "Request.Cookies" command is used to retrieve a cookie value:</p>
<p><%<br />
fname=Request.Cookies("firstname")<br />
response.write("Firstname=" & fname)<br />
%></p>
<h3>Including Files</h3>
<p> You can insert the content of one ASP file into another ASP file before the
server executes it, with the #include directive. The #include directive is used
to create functions, headers, footers, or elements that will be reused on
multiple pages</p>
<p>Syntax:</p>
<p><!--#include virtual="somefile.inc"--><br />
or<br />
<!--#include file ="somefile.inc"--></p>
<p>Use the virtual keyword to indicate a path beginning with a virtual
directory. If a file named "header.inc" resides in a virtual directory named
/html, the following line would insert the contents of "header.inc":</p>
<p><!-- #include virtual ="/html/header.inc" --></p>
<p>Use the file keyword to indicate a relative path. A relative path begins with
the directory that contains the including file. If you have a file in the html
directory, and the file "header.inc" resides in html\headers, the following line
would insert "header.inc" in your file:</p>
<p><!-- #include file ="headers\header.inc" --></p>
<p>Use the file keyword with the syntax (..\) to include a file from a
higher-level directory.</p>
<h3>Global.asa</h3>
<p>The Global.asa file is an optional file that can contain declarations of
objects, variables, and methods that can be accessed by every page in an ASP
application.</p>
<p> <b>Note:</b> The Global.asa file must be stored in the
root directory of the ASP application, and each application can only have one
Global.asa file.</p>
<p>The Global.asa file can contain only the following:</p>
<ul>
<li>Application events </li>
<li>Session events </li>
<li><object> declarations </li>
<li>TypeLibrary declarations </li>
<li>the #include directive</li>
</ul>
<p><b>Application and Session Events</b></p>
<p>In Global.asa you can tell the application and session objects what to do
when the application/session starts and what to do when the application/session
ends. The code for this is placed in event handlers. <b>Note:</b> We do not use
<% and %>, to
insert scripts in the Global.asa file, we have to put the subroutines inside the
HTML <script> tag:</p>
<p><script language="vbscript" runat="server"><br />
sub Application_OnStart<br />
' some code<br />
end sub<br />
sub Application_OnEnd<br />
' some code<br />
end sub<br />
sub Session_OnStart<br />
' some code<br />
end sub<br />
sub Session_OnEnd<br />
' some code<br />
end sub<br />
</script></p>
<p><b><object> Declarations</b></p>
<p>It is also possible to create objects with session or application scope in
Global.asa by using the <object> tag. <b>Note:</b> The <object> tag should be
outside the <script> tag!</p>
<p>Syntax:</p>
<p><object runat="server" scope="scope" id="id"<br />
{progid="progID"|classid="classID"}><br />
.......<br />
</object></p>
<p><b>TypeLibrary Declarations</b></p>
<p>A TypeLibrary is a container for the contents of a DLL file corresponding to
a COM object. By including a call to the TypeLibrary in the Global.asa file,
the constants of the COM object can be accessed, and errors can be better
reported by the ASP code. If your Web application relies on COM objects that
have declared data types in type libraries, you can declare the type libraries
in Global.asa.</p>
<p>Syntax:</p>
<p> <!--METADATA TYPE="TypeLib"<br />
file="filename"<br />
uuid="typelibraryuuid"<br />
version="versionnumber"<br />
lcid="localeid"<br />
--></p>
<h3>The Session Object</h3>
<p>The Session object is used to store information about, or change settings for
a user session. Variables stored in the Session object hold information about
one single user, and are available to all pages in one application.</p>
<p><b>Collections</b></p>
<ul>
<li>
Contents - Holds every item added to the session with script commands</li>
<li>
StaticObjects - Holds every object added to the session with the <object> tag, and a given session</li>
<li>
Contents.Remove(<i>item/index</i>) - Deletes an item from the Contents collection</li>
<li>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -