⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 asp_globalasa.asp@output=print

📁 W3Schools tutorial..web designing
💻 ASP@OUTPUT=PRINT
📖 第 1 页 / 共 2 页
字号:
<h3>
Syntax
</h3>
<table class="ex" cellspacing="0" border="1" width="100%" cellpadding="3">
  <tr valign="top">
    <td>
      <pre>&lt;!--METADATA TYPE=&quot;TypeLib&quot;
file=&quot;filename&quot;
uuid=&quot;typelibraryuuid&quot;
version=&quot;versionnumber&quot;
lcid=&quot;localeid&quot;
--&gt;</pre>
    </td>
  </tr>
</table>
<br />
<table class="ex" cellspacing="0" border="1" width="100%" cellpadding="3"> 
  <tr>
    <th align="left" valign="top" width="20%">Parameter</th>
    <th align="left" valign="top" width="80%">Description</th>
  </tr>  
  <tr>
    <td valign="top">file</td>
    <td valign="top">Specifies an absolute path to a type library.
      <p>Either the file parameter or the uuid parameter is required</p>
    </td>
  </tr>
  <tr>
    <td valign="top">uuid</td>
    <td valign="top">Specifies a unique identifier for the type library.
      <p>Either the file parameter or the uuid parameter is required</p>
    </td>
  </tr>
  <tr>
    <td valign="top">version</td>
    <td valign="top">Optional. Used for selecting version. If the requested version is not found, then the most recent version is used</td>
  </tr>
  <tr>
    <td valign="top">lcid</td>
    <td valign="top">Optional. The locale identifier to be used for the type library</td>
  </tr>
</table>

<h3>Error Values</h3>

<p>
The server can return one of the following error messages:</p>

<table class="ex" cellspacing="0" border="1" width="100%" cellpadding="3"> 
  <tr>
    <th align="left" valign="top" width="20%">Error Code</th>
    <th align="left" valign="top" width="80%">Description</th>
  </tr>  
  <tr>
    <td valign="top">ASP 0222</td>
    <td valign="top"> Invalid type library specification
    </td>
  </tr>
  <tr>
    <td valign="top">ASP 0223</td>
    <td valign="top"> Type library not found
    </td>
  </tr>
  <tr>
    <td valign="top">ASP 0224</td>
    <td valign="top"> Type library cannot be loaded</td>
  </tr>
  <tr>
    <td valign="top">ASP 0225</td>
    <td valign="top"> Type library cannot be wrapped</td>
  </tr>
</table>

<p><b>Note:</b> METADATA tags can appear anywhere in the Global.asa
file (both inside and outside &lt;script&gt; tags). However, it is recommended that
METADATA tags appear near the top of the Global.asa file.
</p>
<hr />

<h2>Restrictions</h2>
<p>Restrictions on what you can include in the Global.asa file:
</p>
<ul>
  <li> You can not display text that is written in the Global.asa file. This file
can't display information</li>
  <li>You can only use Server and Application objects in the Application_OnStart and Application_OnEnd
subroutines. In the&nbsp;Session_OnEnd subroutine, you can use Server, Application, and Session
    objects. In the Session_OnStart subroutine you can use any built-in object</li>
</ul>
<hr />

<h2>How to use the Subroutines</h2>

<p>Global.asa is often used to initialize variables.&nbsp;</p>

<p> The
example below shows how to detect the exact time a visitor first arrives on a Web site. The time is stored in a Session variable named 
&quot;started&quot;,
and the value of the &quot;started&quot; variable can be accessed from any ASP page in the
application:</p>

<table class="ex" cellspacing="0" border="1" width="100%" cellpadding="3">
  <tr valign="top">
    <td>
      <pre>&lt;script language=&quot;vbscript&quot; runat=&quot;server&quot;&gt;
sub Session_OnStart
Session(&quot;started&quot;)=now()
end sub
&lt;/script&gt;</pre>
    </td>
  </tr>
</table>

<p>Global.asa can also be used to control page access.
</p>

<p>The example
below shows how to redirect every new visitor to another page, in this case to a
page called &quot;newpage.asp&quot;:
</p>
<table class="ex" cellspacing="0" border="1" width="100%" cellpadding="3">
  <tr valign="top">
    <td>
      <pre>&lt;script language=&quot;vbscript&quot; runat=&quot;server&quot;&gt;
sub Session_OnStart
Response.Redirect(&quot;newpage.asp&quot;)
end sub
&lt;/script&gt;</pre>
    </td>
  </tr>
</table>
<p>And you can include functions in the Global.asa file.
</p>
<p>In the example below
the Application_OnStart subroutine occurs when the Web server starts. Then
the Application_OnStart subroutine calls another subroutine named &quot;getcustomers&quot;.
The &quot;getcustomers&quot; subroutine opens a database and retrieves a record set from
the &quot;customers&quot; table. The record set is assigned to an array, where it
can be accessed from any ASP page without querying the database:
</p>
<table class="ex" cellspacing="0" border="1" width="100%" cellpadding="3">
  <tr valign="top">
    <td>
      <pre>&lt;script language=&quot;vbscript&quot; runat=&quot;server&quot;&gt;</pre>
      <pre>sub Application_OnStart
getcustomers
end sub</pre>
      <pre>sub getcustomers&nbsp;
set conn=Server.CreateObject(&quot;ADODB.Connection&quot;)
conn.Provider=&quot;Microsoft.Jet.OLEDB.4.0&quot;
conn.Open &quot;c:/webdata/northwind.mdb&quot;
set rs=conn.execute(&quot;select name from customers&quot;)
Application(&quot;customers&quot;)=rs.GetRows
rs.Close
conn.Close
end sub</pre>
      <pre>&lt;/script&gt;</pre>
    </td>
  </tr>
</table>
<br />
<hr />
<h2>Global.asa Example
</h2>
<p>In this example we will create a Global.asa file that counts the number of
current visitors.
</p>
<ul>
  <li>The Application_OnStart sets the Application variable &quot;visitors&quot; to 0 when
    the server starts</li>
  <li>The Session_OnStart subroutine adds one to the variable &quot;visitors&quot; every time a new visitor
    arrives</li>
  <li>The
Session_OnEnd subroutine subtracts one from &quot;visitors&quot; each time this subroutine is
    triggered</li>
</ul>
<p>The Global.asa file:
</p>
<table class="ex" cellspacing="0" border="1" width="100%" cellpadding="3">
  <tr valign="top">
    <td>
      <pre>&lt;script language=&quot;vbscript&quot; runat=&quot;server&quot;&gt;</pre>
      <pre>Sub Application_OnStart
Application(&quot;visitors&quot;)=0
End Sub</pre>
      <pre>Sub Session_OnStart
Application.Lock
Application(&quot;visitors&quot;)=Application(&quot;visitors&quot;)+1
Application.UnLock
End Sub</pre>
      <pre>Sub Session_OnEnd
Application.Lock
Application(&quot;visitors&quot;)=Application(&quot;visitors&quot;)-1
Application.UnLock
End Sub</pre>
      <pre>&lt;/script&gt;</pre>
    </td>
  </tr>
</table>
<p>To display the number of current visitors in an ASP file:
</p>
<table class="ex" cellspacing="0" border="1" width="100%" cellpadding="3">
  <tr valign="top">
    <td>
      <pre>&lt;html&gt;
&lt;head&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;p&gt;
There are &lt;%response.write(Application(&quot;visitors&quot;))%&gt;
online now!
&lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
    </td>
  </tr>
</table>
<br />
<hr />
<a href="asp_incfiles.asp"><img alt="previous" border="0" src="../images/btn_previous.gif" width="100" height="20" /></a>
<a href="asp_send_email.asp"><img alt="next" border="0" src="../images/btn_next.gif" width="100" height="20" /></a>

<p>From <b>http://www.w3schools.com</b> (Copyright Refsnes Data)</p>

</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -