<html>
<head>
<link rel="stylesheet" href="josh.css">
</head>
<body bgcolor="#FFFFFF">
<div id="Application">
  <table cellpadding="0" cellspacing="0" border="0" width="100%" class="main">
    <tr>
      <td valign="top" class="name">Application</td>
      <td valign="top" nowrap class="compatibility"> </td>
    </tr>
    <tr>
      <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
    </tr>
    <tr>
      <td valign="top" class="usage" nowrap><p class="literal">HttpApplicationState =
          Page.Application</p></td>
      <td valign="top" align="right">&nbsp;</td>
    </tr>
    <tr>
      <td colspan="2" class="clearseparation">&nbsp;</td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="description"><p>Returns an instance
          of the <span class="literal">HttpApplicationState</span> class, which
          is the equivalent of the ASP intrinsic Application object. An instance
          of the <span class="literal">HttpApplicationState</span> class contains
          global information that can be shared across multiple sessions and requests
          within an ASP.NET application. For more information on the HttpApplicationState
          class and its members, see Chapter 13. </p></td>
    </tr>
    <tr>
      <td colspan="2" class="clearseparation">&nbsp;</td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="parameters"><span class="title">Parameters</span>
        <ul>
          <li><span class="literal">HttpApplicationState</span> <br>&nbsp;A variable of
            type HttpApplicationState that receives the instance of the <span class="literal">HttpApplicationState</span>
            class. </li>
        </ul></td>
    </tr>
    <tr>
      <td colspan="2" class="clearseparation">&nbsp;</td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="example"><span class="title">Example</span>
        </td>
    </tr>
    <tr>
      <td><p>The following code example uses Page object's Application property
          to add a name/value pair to the Application object and display the value
          in a label control. Since all of the properties of the Page object are
          exposed directly to any code associated with the page, it is not necessary
          to explicitly name the <span class="literal">Page</span> class (i.e.,
          <span class="literal">Page.Application</span>) to access the Application
          property. </p><span class="programlisting">
<pre>
Sub Page_Load( )
	Application(&quot;Name&quot;) = &quot;John Doe&quot;
	Message.Text = &quot;The value &lt;em&gt;&quot; &amp;CStr(Application(&quot;Name&quot;)) &amp;_
		&quot;&lt;/em&gt; has been added to the Application collection.&quot;
End Sub</pre></span></td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="notes"><span class="title">Notes</span>
        </td>
    </tr>
    <tr>
      <td><p>Although you can retrieve a local object reference to the HttpApplicationState
          instance for the application, the more common use of this property is
          to access it directly through the Application property, as shown in
          the example.</p></td>
    </tr>
  </table>
</div>
<div id="Cache">
  <table cellpadding="0" cellspacing="0" border="0" width="100%" class="main">
    <tr>
      <td valign="top" class="name">Cache</td>
      <td valign="top" nowrap class="compatibility"> </td>
    </tr>
    <tr>
      <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
    </tr>
    <tr>
      <td valign="top" class="usage" nowrap><p class="literal">Cache = Page.Cache</p></td>
      <td valign="top" align="right">&nbsp;</td>
    </tr>
    <tr>
      <td colspan="2" class="clearseparation">&nbsp;</td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="description"><p>Returns an instance
          of the Cache class, which represents the cache for an application domain.
          Using the Cache property, data can be added to and retrieved from the
          cache. </p></td>
    </tr>
    <tr>
      <td colspan="2" class="clearseparation">&nbsp;</td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="parameters"><span class="title">Parameters</span>
        <ul>
          <li><span class="literal">Cache</span> <br>&nbsp;A variable of type Cache that
            will receive the Cache instance.</li>
        </ul></td>
    </tr>
    <tr>
      <td colspan="2" class="clearseparation">&nbsp;</td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="example"><span class="title">Example</span>
        </td>
    </tr>
    <tr>
      <td><p>The following code example adds two name/value pairs to the Cache object
          using the Cache property of the Page class and displays the values in
          a label control using the Page object's Cache property: </p><span class="programlisting">
 <pre>
Sub Page_Load(o As Object, e As EventArgs)
	Cache(&quot;Name&quot;) = &quot;John Doe&quot;
	Cache(&quot;Age&quot;) = 42
	Message.Text = CStr(Cache.Item(&quot;Name&quot;))&amp; &quot; is &quot; &amp;_
		CStr(Cache(&quot;Age&quot;)) &amp; &quot; years old.&quot;
End Sub</pre></span></td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="notes"><span class="title">Notes</span>
        </td>
    </tr>
    <tr>
      <td><p>Like the Application object, the Cache object is more commonly accessed
          directly through the Cache property, rather than by obtaining a local
          object reference to the Cache instance for the application. Chapter
          13 discusses when you might use the ASP.NET Cache rather than the Application
          state collection, and vice-versa. The <span class="literal">Cache</span>
          class includes the following members:
        </p>
        <table border="1">
          <tbody>
            <tr>
              <td>Cache member</td>
              <td>Description</td>
            </tr>
            <tr>
              <td>Add method </td>
              <td>Adds an item to the cache</td>
            </tr>
            <tr>
              <td>Count property </td>
              <td>Indicates the number of items contained in the cache</td>
            </tr>
            <tr>
              <td>Get method </td>
              <td>Returns an object representing data in the cache with a particular
                key value </td>
            </tr>
            <tr>
              <td>Insert method </td>
              <td>Inserts an item into the cache and assigns it a key</td>
            </tr>
            <tr>
              <td>Item property </td>
              <td>Returns an object representing a cache item based on its key
                value or sets an item of data in the cache while assigning it
                a key value </td>
            </tr>
            <tr>
              <td>Remove method </td>
              <td>Removes an item with a particular key value from the cache</td>
            </tr>
          </tbody>
        </table></td>
    </tr>
  </table>
</div>
<div id="ClientTarget">
  <table cellpadding="0" cellspacing="0" border="0" width="100%" class="main">
    <tr>
      <td valign="top" class="name">ClientTarget</td>
      <td valign="top" nowrap class="compatibility"> </td>
    </tr>
    <tr>
      <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
    </tr>
    <tr>
      <td valign="top" class="usage" nowrap><p class="literal">String = Page.ClientTarget</p></td>
      <td valign="top" align="right">&nbsp;</td>
    </tr>
    <tr>
      <td colspan="2" class="clearseparation">&nbsp;</td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="description"> <p>Gets or sets a string
          value that allows you to override automatic browser detection in ASP.NET,
          force the page to be rendered for a browser type configured in <span class="emphasis">machine.config</span>
          or <span class="emphasis">web.config</span>, and specified by this property. The available
          preconfigured values for this property are: </p>
          <ul>
        <li><span class="literal">downlevel<span>
              <br>&nbsp;The page will be rendered based on the browser capabilities
                defined for unknown browsers in the &lt;browserCaps&gt; element
                of machine.config. </span>
         <li><span class="literal">ie4 value</span>
              <br>&nbsp;The page will be rendered based on the values for Internet Explorer
                4.0 configured in the &lt;browserCaps&gt; element of <span class="emphasis">machine.config</span>.
              </li>
           <li><span class="literal">ie5</span>
              <br>&nbsp;The page will be rendered based on the values for Internet Explorer
                5.0 configured in the &lt;browserCaps&gt; element of machine.config.
              </li>
           </ul></td>
    </tr>
    <tr>
      <td colspan="2" class="clearseparation">&nbsp;</td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="parameters"><span class="title">Parameters</span>
        <ul>
          <li><span class="literal">String</span> <br>&nbsp;A string that specifies the
            alias for the browser capabilities that the page will target. </li>
        </ul></td>
    </tr>
    <tr>
      <td colspan="2" class="clearseparation">&nbsp;</td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="example"><span class="title">Example</span>
        </td>
    </tr>
    <tr>
      <td><p>The following code example initializes the ClientTarget property of
          the<span class="literal"> Page</span> class to <span class="literal">downlevel</span>,
          indicating that ASP.NET must render the page for an unknown browser
          type, which will result in HTML 3.2-compliant output. The example then
          displays a message indicating whether a set of features is supported.
          In the case of <span class="literal">downlevel</span>, none of the listed
          features is supported. </p><span class="programlisting">
          <pre>
Sub Page_Load( )
	Page.ClientTarget = &quot;downlevel&quot;
		Message.Text= &quot;Page is set to render for the &quot; &amp;_
	Page.ClientTarget &amp; &quot; alias.&lt;br/&gt;&quot;
	Message.Text &amp;= &quot;Supported features:&lt;br/&gt;&quot;
	Message.Text &amp;= &quot;_JavaScript: &quot; &amp;_
		Request.Browser.JavaScript &amp; &quot;&lt;br/&gt;&quot;
	Message.Text &amp;= &quot;- ActiveX Controls: &quot; &amp;_
		Request.Browser.ActiveXControls &amp; &quot;&lt;br/&gt;&quot;
	Message.Text &amp;= &quot;- Frames: &quot; &amp;_
		Request.Browser.Frames &amp; &quot;&lt;br/&gt;&quot;
End Sub</pre> </span></td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="notes"><span class="title">Notes</span>
        </td>
    </tr>
    <tr>
      <td><p>The ClientTarget can also be specified by using the <span class="literal">ClientTarget</span>
          attribute of the <span class="literal">@ Page</span> directive. Changing
          the value of the <span class="literal"> ClientTarge</span>t property
          in the example to <span class="literal">ie4</span> will result in output
          indicating that all of the listed features are supported.</p>
        </td>
    </tr>
    <tr>
      <td colspan="2" class="clearseparation">&nbsp;</td>
    </tr>
    <tr>
      <td><p> While most server controls render HTML 3.2 for all browsers, the validation
          controls are an example of controls that render differently, depending
          on the value of ClientTarget. If the ClientTarget property is set to
          <span class="literal">downlevel</span>, then validation is performed
          on the server side, meaning that if we view the source, no client-side
          script will perform the validation. If the ClientTarget is set to <span class="literal">uplevel</span>,
          then the validation controls emit client-side JavaScript to perform
          client-side validation. </p></td>
    </tr>
  </table>
</div>
<div id="Context">
  <table cellpadding="0" cellspacing="0" border="0" width="100%" class="main">
    <tr>
      <td valign="top" class="name">Context</td>
      <td valign="top" nowrap class="compatibility"> </td>
    </tr>
    <tr>
      <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
    </tr>
    <tr>
      <td valign="top" class="usage" nowrap><p class="literal">HttpContext = Page.Context</p></td>
      <td valign="top" align="right">&nbsp;</td>
    </tr>
    <tr>
     <td colspan="2" class="clearseparation">&nbsp;</td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="description"> <p>Returns an HttpContext
          instance containing context information for the current HTTP request.
        </p></td>
    </tr>
    <tr>
      <td colspan="2" class="clearseparation">&nbsp;</td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="parameters"><span class="title">Parameters</span>
        <ul>
          <li><span class="literal">HttpContext</span> <br>&nbsp;A variable of type HttpContext
            that will receive the reference to the current HttpContext instance.
          </li>
        </ul></td>
    </tr>
    <tr>
      <td colspan="2" class="clearseparation">&nbsp;</td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="example"><span class="title">Example</span>
        </td>
    </tr>
    <tr>
      <td><p>The following code example uses the Context property to return the
          name of the currently logged in user. This information is also available
          from the User property of the <span class="literal">Page</span> class,
          which is derived from the HttpContext associated with the current request.
          </p><span class="programlisting">
          <pre>
Sub Page_Load( )
	Message.Text = &quot;Currently logged in as: &quot; &amp;_
		Context.User.Identity.Name
End Sub </pre></span></td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="notes"><span class="title">Notes</span>
        </td>
    </tr>
    <tr>
      <td><p>A common use of this property is to pass a reference to the <span class="literal">HttpContext</span>
          for the current request to a business object that needs access to the
          ASP.NET intrinsic objects (Request, Response, etc.). In addition to
          providing access to the Application, Request, Response, Server, and
          Session intrinsics, the HttpContext class provides access to the Trace
          and User information for the current HTTP request. </p></td>
    </tr>
  </table>
</div>
<div id="EnableViewState">
  <table cellpadding="0" cellspacing="0" border="0" width="100%" class="main">
    <tr>
      <td valign="top" class="name">EnableViewState</td>
      <td valign="top" nowrap class="compatibility"> </td>
    </tr>
    <tr>
      <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
    </tr>
    <tr>
      <td valign="top" class="usage" nowrap><p class="literal">Boolean = Page.EnableViewState
          <br>Page.EnableViewState = Boolean</p></td>
      <td valign="top" align="right">&nbsp;</td>
    </tr>
    <tr>
      <td colspan="2" class="clearseparation">&nbsp;</td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="description"> <br>Returns or sets a Boolean
          value that indicates whether the Page maintains its view state and that
          of server controls it contains. The default value of this property is
          <span class="literal">True</span>, which means that the page maintains
          its view state.</td>
    </tr>
    <tr>
      <td colspan="2" class="clearseparation">&nbsp;</td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="parameters"><span class="title">Parameters</span>
        <ul>
          <li><span class="literal">Boolean</span> <br>&nbsp;A Boolean value that indicates
            whether the page maintains its view state. </li>
        </ul></td>
    </tr>
    <tr>
      <td colspan="2" class="clearseparation">&nbsp;</td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="example"><span class="title">Example</span>
        </td>
    </tr>
    <tr>
      <td><p>The following code example sets EnableViewState to <span class="literal">False</span>
          using the <span class="literal">EnableViewState</span> attribute of
          the <span class="literal">@ Page</span> directive and displays its value
          on the page: </p><span class="programlisting">
          <pre>
&lt;%@ Page Language=&quot;vb&quot; EnableViewState=&quot;True&quot; %&gt;
&lt;html&gt;
	&lt;head&gt;
		&lt;title&gt;&lt;/title&gt;
		&lt;script runat=&quot;server&quot;&gt;
			Sub Page_Load( )
				If Page.EnableViewState = True Then
					Message.Text =&quot;ViewState is enabled.&quot;
				Else
					Message.Text = &quot;ViewState is disabled.&quot;
				End If
			End Sub
		&lt;/script&gt;
	&lt;/head&gt;
&lt;body&gt;
	&lt;form runat=&quot;server&quot;&gt;
		&lt;asp:label id=&quot;Message&quot; runat=&quot;server&quot;/&gt;
	&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;</pre></span></td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="notes"><span class="title">Notes</span>
        </td>
    </tr>
    <tr>
      <td><p>The EnableViewState property can also be specified using the EnableViewState
          attribute of the @ Page directive, as shown in the example. Examining
          a page's HTML source using a browser's View Source feature shows the
          effect of the EnableViewState property. If the EnableViewState property
          is set to <span class="literal">False</span>, the source will look similar
          to:
        </p><span class="programlisting">
        <pre>
&lt;input type=&quot;hidden&quot; name=&quot;_ _VIEWSTATE&quot;
	value=&quot;dDwxMDA3MzE2MzEyOzs+&quot;/&gt;</pre></span>
        </td>
    </tr>
    <tr>
      <td><p>If the EnableViewState property is set to <span class="literal">True</span>,
          the source will look similar to:</p><span class="programlisting">
          <pre>
&lt;input type=&quot;hidden&quot; name=&quot;_ _VIEWSTATE&quot;
	value=&quot;dDwxMDA3MzE2MzEyO3Q8O2w8aTwxPjs+O2w8dDw7bDxpPDM+Oz47bDx0PHA8cDxsPF
	RleHQ7PjtsPFZhbHVlIG9mIHRoZSBFbmFibGVWaWV3U3RhdGUgcHJvcGVydHkgaXMgVHJ1ZTs
	+Pjs+Ozs+Oz4+Oz4+Oz4=&quot; /&gt;</pre></span>
          </td>
    </tr>
    <tr>
      <td><p>The extra characters in the value of the
          <span class="literal">_ _VIEWSTATE</span> hidden field indicate the
          view state of the current page. The view state of a page includes the
          transient properties of server controls, such as BackColor or ForeColor.
          Note that pages that do not contain a &lt;form&gt; element with the
          runat=&quot;server&quot; attribute will not save view state, regardless of the
          value of the EnableViewState property.</p> </td>
    </tr>
  </table>
</div>
<div id="ErrorPage">
  <table cellpadding="0" cellspacing="0" border="0" width="100%" class="main">
    <tr>
      <td valign="top" class="name">ErrorPage</td>
      <td valign="top" nowrap class="compatibility"> </td>
    </tr>
    <tr>
      <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
    </tr>
    <tr>
      <td valign="top" class="usage" nowrap><p class="literal">String = Page.ErrorPage
          <br>Page.ErrorPage = String</p></td>
      <td valign="top" align="right">&nbsp;</td>
    </tr>
    <tr>
      <td colspan="2" class="clearseparation">&nbsp;</td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="description"><br>Returns or sets the
          name of the page to redirect to in the event of an unhandled page exception.
        </td>
    </tr>
    <tr>
      <td colspan="2" class="clearseparation">&nbsp;</td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="parameters"><span class="title">Parameters</span>
        <ul>
          <li><span class="literal">String</span> <br>&nbsp;A String value that indicates
            the name of the page to redirect to in the event of an unhandled page
            exception. </li>
        </ul></td>
    </tr>
    <tr>
      <td colspan="2" class="clearseparation">&nbsp;</td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="example"><span class="title">Example</span>
        </td>
    </tr>
    <tr>
      <td><p>The example below changes the ErrorPage property and shows that executed
          page when an unhandled exception occurs in the page:</p><span class="programlisting">
          <pre>
Sub Page_Load( )
	Page.ErrorPage = &quot;ErrorPage_Handler.aspx&quot;
	Dim x, y, overflow As Integer
	x = 1
	y = 0
	overflow = x/y
	'This code will not be executed
	Message.Text = &quot;Error Page is &quot; &amp; Page.ErrorPage &amp; &quot;.&quot;
End Sub</pre></span>
</td>
    </tr>
    <tr>
      <td><p> The Page_Load for <span class="emphasis">ErrorPage_Handler.aspx</span> is shown
          below:</p><span class="programlisting">
          <pre>
Sub Page_Load( )
	Message.Text = &quot;We're sorry. An error occurred during the&quot; &amp;_
		&quot; processing of your request. Please try again later.&quot;
End Sub</pre></span></td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="notes"><span class="title">Notes</span>
        </td>
    </tr>
    <tr>
      <td><p>The <span class="literal">ErrorPage</span> property can also be specified
          using the ErrorPage attribute of the <span class="literal">@ Page</span>
          directive. </p></td>
    </tr>
  </table>
</div>
<div id="IsPostBack">
  <table cellpadding="0" cellspacing="0" border="0" width="100%" class="main">
    <tr>
      <td valign="top" class="name">IsPostBack</td>
      <td valign="top" nowrap class="compatibility"> </td>
    </tr>
    <tr>
      <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
    </tr>
    <tr>
      <td valign="top" class="usage" nowrap><p class="literal">Boolean = Page.IsPostBack</p></td>
      <td valign="top" align="right">&nbsp;</td>
    </tr>
    <tr>
      <td colspan="2" class="clearseparation">&nbsp;</td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="description"><p>Returns a Boolean value
          that indicates if the page is loaded for the first time <span class="literal">(False)</span>
          or is loaded as a result of the client postback <span class="literal">(True)</span>.
          This property comes handy for the logic that needs to be executed the
          first time the page is executed or every time the page is posted back
          to itself, depending on how you structure your<span class="literal">
          If</span> statement. </p></td>
    </tr>
    <tr>
      <td colspan="2" class="clearseparation">&nbsp;</td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="parameters"><span class="title">Parameters</span>
        <ul>
          <li><span class="literal">Boolean</span> <br>&nbsp;A Boolean value that indicates
            if the page is loaded for the first time or is loaded as a result
            of the client postback. </li>
        </ul></td>
    </tr>
    <tr>
      <td colspan="2" class="clearseparation">&nbsp;</td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="example"><span class="title">Example</span>
        </td>
    </tr>
    <tr>
      <td><p>The code example below uses the IsPostBack property to display different
          messages in the Label control, depending on whether the page is loaded
          for the first time or is loaded as a result of the client postback.
          The first time the page is loaded, the IsPostBack property returns <span class="literal">False</span>,
          causing the string &quot;Non-PostBack&quot; to be displayed. Clicking the button
          posts the page back to itself, causing IsPostBack to return <span class="literal">True</span>
          and the string &quot;PostBack&quot; to be displayed. </p><span class="programlisting">
          <pre>
&lt;%@ Page Language=&quot;vb&quot; %&gt;
&lt;html&gt;
	&lt;head&gt;
		&lt;title&gt;&lt;/title&gt;
		&lt;script runat=&quot;server&quot;&gt;
			Sub Page_Load( )
				If Page.IsPostBack Then
					Message.Text = &quot;PostBack&quot;
				Else
					Message.Text = &quot;Non-PostBack&quot;
				End If
			End Sub
		&lt;/script&gt;
	&lt;/head&gt;
&lt;body&gt;
	&lt;form runat=&quot;server&quot;&gt;
		&lt;asp:button id=&quot;post&quot; Text=&quot;Post page&quot; runat=&quot;server&quot;/&gt;
		&lt;asp:label id=&quot;Message&quot; runat=&quot;server&quot;/&gt;
	&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;</pre></span></td>
    </tr>
     <tr>
      <td valign="top" colspan="2" class="notes"><span class="title">Notes</span>
        </td>
    </tr>
    <tr>
      <td><p>The IsPostBack property will return <span class="literal">True</span>
          only for pages that contain a <span class="literal">&lt;form&gt;</span>
          element with the <span class="literal">runat=&quot;server&quot;</span> attribute
          and at least one control that causes a postback. This can be a Button
          control, as shown in the example, or another control, such as a DropDownList
          control, whose <span class="literal">AutoPostBack</span> property is
          set to <span class="literal">True.</span> </p></td>
    </tr>
  </table>
</div>
<div id="IsValid">
  <table cellpadding="0" cellspacing="0" border="0" width="100%" class="main">
    <tr>
      <td valign="top" class="name">IsValid</td>
      <td valign="top" nowrap class="compatibility"> </td>
    </tr>
    <tr>
      <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
    </tr>
    <tr>
      <td valign="top" class="usage" nowrap><p class="literal">Boolean = Page.IsValid</p></td>
      <td valign="top" align="right">&nbsp;</td>
    </tr>
    <tr>
      <td colspan="2" class="clearseparation">&nbsp;</td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="description"><p>ReturnsIs a Boolean
          value, indicating whether any validation controls on the page were unable
          to successfully validate user input. </p></td>
    </tr>
    <tr>
      <td colspan="2" class="clearseparation">&nbsp;</td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="parameters"><span class="title">Parameters</span>
        <ul>
          <li><span class="literal">Boolean</span> <br>&nbsp;A Boolean indicating whether
            the validation succeeded.</li>
        </ul></td>
    </tr>
    <tr>
      <td colspan="2" class="clearseparation">&nbsp;</td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="example"><span class="title">Example</span>
        </td>
    </tr>
    <tr>
      <td><p>The example uses the IsValid property to determine whether validation
          on the current page succeeded, and displays a message: </p><span class="programlisting">
          <pre>
&lt;%@ Page Language=&quot;vb&quot; %&gt;
&lt;html&gt;
	&lt;head&gt;
		&lt;title&gt;&lt;/title&gt;
		&lt;script runat=&quot;server&quot;&gt;
			Sub Page_Load( )
				If IsPostBack Then Page.Validate()
					If Page.IsValid Then
						Message.Text = &quot;Page is valid.&quot;
					Else
						Message.Text = &quot;Page is not valid.&quot;
					End If
				End If
			End Sub
		&lt;/script&gt;
	&lt;/head&gt;
&lt;body&gt;
	&lt;form runat=&quot;server&quot;&gt;
	    Enter your name:
		&lt;asp:textbox id=&quot;name&quot; runat=&quot;server&quot;/&gt;
		&lt;asp:requiredfieldvalidator
			id=&quot;rfvName&quot;
			controltovalidate=&quot;name&quot;
			enableclientscript=&quot;false&quot;
			errormessage=&quot;Required!&quot;
			runat=&quot;server&quot;/&gt;
		&lt;br/&gt;
		&lt;asp:button id=&quot;submit&quot; Text=&quot;Submit&quot; runat=&quot;server&quot;/&gt;
		&lt;br/&gt;
		&lt;asp:label id=&quot;Message&quot; runat=&quot;server&quot;/&gt;
	&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;</pre></span></td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="notes"><span class="title">Notes</span>
        </td>
    </tr>
    <tr>
      <td><p>The IsValid property determines whether the overall validation performed
          by a form's validator controls has succeeded. If the page has no validator
          controls, the property's value is always <span class="literal">True</span>.
          Before checking the value of IsValid, you must either call the Page.Validate
          method, as shown in the example, or have submitted the page with a control
          (such as a Button, ImageButton, or LinkButton control) whose CausesValidation
          property is set to <span class="literal">True</span>. Otherwise, an
          exception will occur.</p>
        </td>
    </tr>
    <tr>
      <td colspan="2" class="clearseparation">&nbsp;</td>
    </tr>
    <tr>
      <td><p>In the example, the <span class="literal">EnableClientScript</span>
          property of the RequiredFieldValidator control is set to <span class="literal">False</span>,
          which disables client-side validation. By default, client-side validation
          is enabled and the page is never submitted to the server if the validation
          fails. Uplevel browsers perform validation on the client using client-side
          scripts, and only when validation succeeds is the page submitted. Only
          when the page is submitted is the server-side event handler code executed
          and the message displayed based on the value of the IsValid property.</p>
        </td>
    </tr>
    <tr>
      <td colspan="2" class="clearseparation">&nbsp;</td>
    </tr>
    <tr>
      <td><p>Checking the IsValid property is important whether client-side validation
          is enabled, since a malicious client could bypass client-side validation.
        </p></td>
    </tr>
  </table>
</div>
<div id="Request">
  <table cellpadding="0" cellspacing="0" border="0" width="100%" class="main">
    <tr>
      <td valign="top" class="name">Request</td>
      <td valign="top" nowrap class="compatibility"> </td>
    </tr>
    <tr>
      <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
    </tr>
    <tr>
      <td valign="top" class="usage" nowrap><p class="literal">HttpRequest = Page.Request</p></td>
      <td valign="top" align="right">&nbsp;</td>
    </tr>
    <tr>
      <td colspan="2" class="clearseparation">&nbsp;</td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="description"><p>Returns an instance
          of the <span class="literal">HttpRequest</span> class class that allows
          us to access data from the incoming HTTP requests. It's the equivalent
          of the ASP intrinsic Request object. For more information on the HttpRequest
          class, see Chapter 16. </p></td>
    </tr>
    <tr>
      <td colspan="2" class="clearseparation">&nbsp;</td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="parameters"><span class="title">Parameters</span>
        <ul>
          <li><span class="literal">HttpRequest</span> <br>&nbsp;An object of type HttpRequest
            that contains the data from the incoming HTTP requests. </li>
        </ul></td>
    </tr>
    <tr>
      <td colspan="2" class="clearseparation">&nbsp;</td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="example"><span class="title">Example</span>
        </td>
    </tr>
    <tr>
      <td><p>The following code example uses the ServerVariables collection of the
          HttpRequest object to display the IP address of the client making the
          request: </p><span class="programlisting">
          <pre>
Sub Page_Load( )
	Message.Text = &quot;The current request is from: &quot; &amp;_
		CStr(Request.ServerVariables.Item(&quot;REMOTE_ADDRESS&quot;))
End Sub</pre></span></td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="notes"><span class="title">Notes</span>
        </td>
    </tr>
    <tr>
      <td><p>As with the Application and Cache properties, while you can retrieve
          a local reference to the HttpRequest instance associated with the request,
          it is more common to access this instance directly through the Request
          property, as shown in this example. </p></td>
    </tr>
  </table>
</div>
<div id="Response">
  <table cellpadding="0" cellspacing="0" border="0" width="100%" class="main">
    <tr>
      <td valign="top" class="name">Response</td>
      <td valign="top" nowrap class="compatibility"> </td>
    </tr>
    <tr>
      <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
    </tr>
    <tr>
      <td valign="top" class="usage" nowrap><p class="literal">HttpResponse = Page.Response</p></td>
      <td valign="top" align="right">&nbsp;</td>
    </tr>
    <tr>
     <td colspan="2" class="clearseparation">&nbsp;</td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="description"><p>Returns an instance
          of the <span class="literal">HttpResponse</span> class that stores information
          about the response and allows us to send HTTP response data to a browser.
          It's the equivalent of the ASP intrinsic Response object. For information
          on the <span class="literal">HttpResponse</span> class, see Chapter
          17. </p></td>
    </tr>
    <tr>
      <td colspan="2" class="clearseparation">&nbsp;</td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="parameters"><span class="title">Parameters</span>
        <ul>
          <li><span class="literal">HttpResponse</span> <br>&nbsp;An object of type HttpResponse
            that receives the instance of the <span class="literal">HttpResponse</span>
            class. </li>
        </ul></td>
    </tr>
    <tr>
      <td colspan="2" class="clearseparation">&nbsp;</td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="example"><span class="title">Example</span>
        </td>
    </tr>
    <tr>
      <td><p>The following example uses the Response property of the page object
          to set the ContentType property of the <span class="literal">HttpResponse</span>
          class to <span class="literal">text/xml</span>. Setting this property
          will result in the output of the page being displayed as XML markup
          in Internet Explorer 5.0 or above. </p><span class="programlisting">
          <pre>
Sub Page_Load( )
	Response.ContentType = &quot;text/xml&quot;
	Message.Text = &quot;This page will be displayed as XML in &quot; &amp;_
		&quot;Internet Explorer 5.0 or above.&quot;
End Sub</pre></span></td>
    </tr>
     <tr>
      <td valign="top" colspan="2" class="notes"><span class="title">Notes</span>
        </td>
    </tr>
    <tr>
      <td><p>As with the Application and Cache properties, while you can retrieve
          a local reference to the HttpResponse instance associated with the request,
          it is more common to access this instance directly through the Request
          property, as shown in this example. </p></td>
    </tr>
  </table>
</div>
<div id="Server">
  <table cellpadding="0" cellspacing="0" border="0" width="100%" class="main">
    <tr>
      <td valign="top" class="name">Server</td>
      <td valign="top" nowrap class="compatibility"> </td>
    </tr>
    <tr>
      <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
    </tr>
    <tr>
      <td valign="top" class="usage" nowrap><p class="literal">HttpServerUtility = Page.Server</p></td>
      <td valign="top" align="right">&nbsp;</td>
    </tr>
    <tr>
      <td colspan="2" class="clearseparation">&nbsp;</td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="description"><p>Returns an instance
          of the <span class="literal">HttpServerUtility</span> class, which exposes
          useful methods for working with ASP.NET requests. For more information
          on the <span class="literal">HttpServerUtility</span> class, see Chapter
          18. </p></td>
    </tr>
    <tr>
      <td colspan="2" class="clearseparation">&nbsp;</td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="parameters"><span class="title">Parameters</span>
        <ul>
          <li><span class="literal">HttpServerUtility</span> <br>&nbsp;An object of type
            <span class="literal">HttpServerUtility</span> that may be used to
            access useful properties and methods exposed by this class. </li>
        </ul></td>
    </tr>
    <tr>
      <td colspan="2" class="clearseparation">&nbsp;</td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="example"><span class="title">Example</span>
        </td>
    </tr>
    <tr>
      <td><p>The following code example uses the Server property to access the HtmlEncode
          method of the <span class="literal">HttpServerUtility</span> class,
          which allows you to encode HTML tags and characters so that they will
          be displayed to the user, rather than interpreted and rendered by the
          browser:</p><span class="programlisting">
          <pre>
Sub Page_Load( )
	Message.Text = Server.HtmlEncode(&quot;&lt;em&gt;Hello, World!&lt;/em&gt;&quot;)
End Sub</pre></span>
          </td>
    </tr>
    <tr>
      <td><p> The HTML rendered from this page would
          look like the following:</p><span class="programlisting">
          <pre>
&lt;html&gt;
	&lt;head&gt;
		&lt;title&gt; Server property example &lt;/title&gt;
	&lt;/head&gt;
&lt;body&gt;
	&lt;span id=&quot;Message&quot;&gt;&amp;lt;em&amp;gt;Hello,World!&amp;lt;/em&amp;gt; &lt;/span&gt;
&lt;/body&gt;
&lt;/html&gt;</pre></span></td>
    </tr>
     <tr>
      <td valign="top" colspan="2" class="notes"><span class="title">Notes</span>
        </td>
    </tr>
    <tr>
      <td><p>As with the Request and Response properties, while you can retrieve
          a local reference to the HttpServerUtility instance associated with
          the application, it is more common to access this instance directly
          through the Server property, as shown in this example. </p></td>
    </tr>
  </table>
</div>
<div id="Session">
  <table cellpadding="0" cellspacing="0" border="0" width="100%" class="main">
    <tr>
      <td valign="top" class="name">Session</td>
      <td valign="top" nowrap class="compatibility"> </td>
    </tr>
    <tr>
      <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
    </tr>
    <tr>
      <td valign="top" class="usage" nowrap><p class="literal">HttpSessionState = Page.Session</p></td>
      <td valign="top" align="right">&nbsp;</td>
    </tr>
    <tr>
      <td colspan="2" class="clearseparation">&nbsp;</td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="description"> <p>Returns an object that
          represents the current user session. A Session object is maintained
          for each user that requests a page from an ASP.NET application. You
          can store session-specific data in the Session object and then access
          it across multiple pages in an ASP.NET application. For more information
          on the <span class="literal">HttpSessionState</span> class, see Chapter
          19. </p></td>
    </tr>
    <tr>
      <td colspan="2" class="clearseparation">&nbsp;</td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="parameters"><span class="title">Parameters</span>
        <ul>
          <li><span class="literal">HttpSessionState</span> <br>&nbsp;An HttpSessionState
            object that represents the current user session. </li>
        </ul></td>
    </tr>
    <tr>
      <td colspan="2" class="clearseparation">&nbsp;</td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="example"><span class="title">Example</span>
        </td>
    </tr>
    <tr>
      <td><p>The example uses the Session object to display the value of the Mode
          property, which indicates where session state information is stored:
          </p><span class="programlisting">
          <pre>
Sub Page_Load( )
	Message.Text = &quot;Current Session State Mode: &quot; &amp;_
			Session.Mode.ToString( )
End Sub</pre></span></td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="notes"><span class="title">Notes</span>
        </td>
    </tr>
    <tr>
      <td><p>As with the Request and Response properties, while you can retrieve
          a local reference to the HttpSessionState instance associated with the
          request, it is more common to access this instance directly through
          the Session property, as shown in this example. </p></td>
    </tr>
  </table>
</div>
<div id="SmartNavigation">
  <table cellpadding="0" cellspacing="0" border="0" width="100%" class="main">
    <tr>
      <td valign="top" class="name">SmartNavigation</td>
      <td valign="top" nowrap class="compatibility"> </td>
    </tr>
    <tr>
      <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
    </tr>
    <tr>
      <td valign="top" class="usage" nowrap><p class="literal">Boolean = Page.SmartNavigation
          <br>Page.SmartNavigation = Boolean</p></td>
      <td valign="top" align="right">&nbsp;</td>
    </tr>
    <tr>
      <td colspan="2" class="clearseparation">&nbsp;</td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="description"><br>Returns or sets a Boolean
          indicating whether the SmartNavigation feature is turned on. The SmartNavigation
          feature, which is compatible only with Internet Explorer, uses <span class="literal">&lt;iframe&gt;</span>
          elements to allow only portions of the page to be refreshed when the
          page is posted back. This can help eliminate the annoying visual flicker
          associated with postbacks.</td>
    </tr>
    <tr>
      <td colspan="2" class="clearseparation">&nbsp;</td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="parameters"><span class="title">Parameters</span>
        <ul>
          <li><span class="literal">Boolean</span> <br>&nbsp;A Boolean value that indicates
            whether or not SmartNavigation is enabled. </li>
        </ul></td>
    </tr>
    <tr>
      <td colspan="2" class="clearseparation">&nbsp;</td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="example"><span class="title">Example</span>
        </td>
    </tr>
    <tr>
      <td><p>The following code example sets the SmartNavigation property to <span class="literal">True</span>
          using the <span class="literal">SmartNavigation</span> attribute of
          the <span class="literal">@ Page</span> directive. When the page is
          posted back, only the current page will be stored in the browser's history,
          so the Back button will be disabled. </p><span class="programlisting">
          <pre>
&lt;%@ Page Language=&quot;vb&quot; SmartNavigation=&quot;True&quot; %&gt;
&lt;html&gt;
	&lt;head&gt;
		&lt;title&gt; SmartNavigation property example &lt;/title&gt;
		&lt;script runat=&quot;server&quot;&gt;
			Sub Page_Load( )
				Message.Text = &quot;This Label will change.&quot;
				Message2.Text = &quot;This Label will not change.&quot;
			End Sub
			Sub UpdateLabel(Sender As Object, e As EventArgs)
				Message.Text = &quot;This Label has changed.&quot;
			End Sub
		&lt;/script&gt;
	&lt;/head&gt;
&lt;body&gt;
	&lt;form runat=&quot;server&quot;&gt;
		&lt;asp:label id=&quot;Message&quot; runat=&quot;server&quot;/&gt;
		&lt;asp:button id=&quot;update&quot;
			onClick=&quot;UpdateLabel&quot;
			text=&quot;Click to update label text&quot;
			runat=&quot;server&quot;/&gt;
	&lt;/form&gt;
	&lt;asp:label id=&quot;Message2&quot; runat=&quot;server&quot;/&gt;
&lt;/body&gt;
&lt;/html&gt;</pre></span></td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="notes"><span class="title">Notes</span>
        </td>
    </tr>
    <tr>
      <td><p>In addition to eliminating flicker when navigating or posting back,
          <span class="literal">SmartNavigation</span> maintains the current scroll
          position when a page is posted back and maintains only a single page
          in the browser's history, which prevents users from clicking the browser's
          Back button to go to a previous state of the page. While you can set
          this property from code, it is recommended that this property be set
          using the <span class="literal">SmartNavigation</span> attribute of
          the <span class="literal">@ Page</span> directive, as shown in this
          example. </p></td>
    </tr>
  </table>
</div>
<div id="Trace">
  <table cellpadding="0" cellspacing="0" border="0" width="100%" class="main">
    <tr>
      <td valign="top" class="name">Trace</td>
      <td valign="top" nowrap class="compatibility"> </td>
    </tr>
    <tr>
      <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
    </tr>
    <tr>
      <td valign="top" class="usage" nowrap><p class="literal">TraceContext = Page.Trace</p></td>
      <td valign="top" align="right">&nbsp;</td>
    </tr>
    <tr>
      <td colspan="2" class="clearseparation">&nbsp;</td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="description"><p>Returns the TraceContex
          object for the current web request. Tracing provides the details about
          the execution of the web request. The <span class="literal">TraceContext</span>
          class includes the following members: </p>
        <table border="1">
          <tbody>
            <tr>
              <td>Member</td>
              <td>Description</td>
            </tr>
            <tr>
              <td>IsEnabled </td>
              <td>Indicates whether tracing is enabled for the current page.</td>
            </tr>
            <tr>
              <td>TraceMode </td>
              <td>A member of the TraceMode enumeration that indicates how items
                should be sorted. Possible values are SortByCategory and SortByTime.
                The latter is the default value defined in machine.config. </td>
            </tr>
            <tr>
              <td>Warn method </td>
              <td>Writes a message to the trace log using red text.</td>
            </tr>
            <tr>
              <td>Write method </td>
              <td>Writes a message to the trace log.</td>
            </tr>
          </tbody>
        </table></td>
    </tr>
    <tr>
      <td colspan="2" class="clearseparation">&nbsp;</td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="parameters"><span class="title">Parameters</span>
        <ul>
          <li><span class="literal">TraceContext</span> <br>&nbsp;An instance of the <span class="literal">TraceContext</span>
            class.</li>
        </ul></td>
    </tr>
    <tr>
      <td colspan="2" class="clearseparation">&nbsp;</td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="example"><span class="title">Example</span>
        </td>
    </tr>
    <tr>
      <td><p>The example turns tracing on programmatically by using the Trace property
          of the <span class="literal">Page</span> class: </p><span class="programlisting">
          <pre>
Sub Page_Load( )
	If Trace.IsEnabled = True Then
		Message.Text = &quot;Tracing is enabled.&quot;
	Else
		Message.Text = &quot;Tracing is not enabled.&quot;
	End If
End Sub</pre></span></td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="notes"><span class="title">Notes</span>
        </td>
    </tr>
    <tr>
      <td><p>As with the Request and Response properties, while you can retrieve
          a local reference to the TraceContext instance associated with the request,
          it is more common to access this instance directly through the Trace
          property, as shown in the following example. For more information on
          application tracing, see Chapter 10. </p></td>
    </tr>
  </table>
</div>
<div id="User">
  <table cellpadding="0" cellspacing="0" border="0" width="100%" class="main">
    <tr>
      <td valign="top" class="name">User</td>
      <td valign="top" nowrap class="compatibility"> </td>
    </tr>
    <tr>
      <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
    </tr>
    <tr>
      <td valign="top" class="usage" nowrap><p class="literal">IPrincipal = Page.User</p></td>
      <td valign="top" align="right">&nbsp;</td>
    </tr>
    <tr>
      <td colspan="2" class="clearseparation">&nbsp;</td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="description"><p>Returns an instance
          of an object implementing the<span class="literal"> IPrincipal</span>
          interface containing security information about the user making the
          page request. The <span class="literal">IPrincipal</span> interface
          implements the following members: </p>
        <table border="1">
          <tbody>
            <tr>
              <td>Member</td>
              <td>Description</td>
            </tr>
            <tr>
              <td>Identity property </td>
              <td>Returns the IIdentity object representing the user requesting
                the page</td>
            </tr>
            <tr>
              <td>IsInRole property </td>
              <td>Indicates whether the user requesting the page is in a particular
                role</td>
            </tr>
          </tbody>
        </table></td>
    </tr>
    <tr>
      <td colspan="2" class="clearseparation">&nbsp;</td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="parameters"><span class="title">Parameters</span>
        <ul>
          <li><span class="literal">IPrincipal</span> <br>&nbsp;An object variable that
            implements <span class="literal">IPrincipal</span>.</li>
        </ul></td>
    </tr>
    <tr>
      <td colspan="2" class="clearseparation">&nbsp;</td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="example"><span class="title">Example</span>
        </td>
    </tr>
    <tr>
      <td><p>The example obtains the user's authentication status and name using
          the User property and displays it in the browser: </p><span class="programlisting">
          <pre>
Sub Page_Load( )
	Message.Text = &quot;Authenticated: &quot; &amp;_
		User.Identity.IsAuthenticated &amp; &quot;&lt;br/&gt;&quot;
	Message.Text &amp;= &quot;User Name: &quot; &amp; User.Identity.Name
End Sub</pre></span></td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="notes"><span class="title">Notes</span>
        </td>
    </tr>
    <tr>
      <td><p>In order for the IPrincipal object returned by the User property to
          be populated, some form of authentication must be configured in either
          <span class="emphasis">machine.config</span> or <span class="emphasis">web.config</span>, and at a minimum, an authorization
          rule must be configured that excludes anonymous users. If these conditions
          are not met, the IsAuthenticated property of the IIdentity object will
          return <span class="literal">False</span> and the Name property will
          return an empty string. </p></td>
    </tr>
  </table>
</div>
<div id="ViewState">
  <table cellpadding="0" cellspacing="0" border="0" width="100%" class="main">
    <tr>
      <td valign="top" class="name">ViewState</td>
      <td valign="top" nowrap class="compatibility"> </td>
    </tr>
    <tr>
      <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
    </tr>
    <tr>
      <td valign="top" class="usage" nowrap><p class="literal">StateBag = Page.ViewState</p></td>
      <td valign="top" align="right">&nbsp;</td>
    </tr>
    <tr>
      <td colspan="2" class="clearseparation">&nbsp;</td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="description"><p>The ViewState property
          returns an instance of the <span class="literal">StateBag</span> class
          containing state information for server controls on the page. This StateBag
          instance can also be used to store arbitrary data that needs to be preserved
          across multiple requests for the same page. </p></td>
    </tr>
    <tr>
      <td colspan="2" class="clearseparation">&nbsp;</td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="parameters"><span class="title">Parameters</span>
        <ul>
          <li><span class="literal">StateBag</span> <br>&nbsp;An object of type StateBag
            that contains the property values for server controls on the page.
            This StateBag instance can also be used to store arbitrary data that
            needs to be preserved across multiple requests for the same page.
          </li>
        </ul></td>
    </tr>
    <tr>
      <td colspan="2" class="clearseparation">&nbsp;</td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="example"><span class="title">Example</span>
        </td>
    </tr>
    <tr>
      <td><p>The following code example sets the ForeColor property of the Message
          control, and then stores the value of that color in the ViewState StateBag
          instance. If the page is posted back, the code retrieves the color that
          was stored, and depending on the name of the color, changes the color
          from <span class="literal">Red</span> to <span class="literal">Black</span>,
          or vice-versa. </p><span class="programlisting">
          <pre>
&lt;%@ Page Language=&quot;vb&quot; %&gt;
&lt;html&gt;
	&lt;head&gt;
		&lt;title&gt;ViewState property example&lt;/title&gt;
		&lt;script runat=&quot;server&quot;&gt;
			Sub Page_Load()
				Dim LocalColor As System.Drawing.Color
				If IsPostBack Then
					LocalColor = CType(ViewState(&quot;LabelColor&quot;),_
						System.Drawing.Color)
					If LocalColor.Name = &quot;Black&quot; Then
						LocalColor = System.Drawing.Color.Red
					Else
						LocalColor = System.Drawing.Color.Black
					End If
					Message.ForeColor = LocalColor
					Message.Text = &quot;Label color is &quot; &amp; LocalColor.Name ViewState(&quot;LabelColor&quot;) = LocalColor
				Else
					Message.ForeColor = System.Drawing.Color.Black
					LocalColor = Message.ForeColor
					Message.Text = &quot;Label color is &quot; &amp; LocalColor.Name ViewState(&quot;LabelColor&quot;) = LocalColor
				End If
			End Sub
		&lt;/script&gt;
	&lt;/head&gt;
&lt;body&gt;
	&lt;form runat=&quot;server&quot;&gt;
		&lt;asp:button id=&quot;button&quot;
			text=&quot;Click to change label color&quot;
			runat=&quot;server&quot;/&gt;
		&lt;asp:label id=&quot;Message&quot; runat=&quot;server&quot;/&gt;
	&lt;/form&gt;
&lt;/body&gt;
&lt;/html&gt;</pre></span></td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="notes"><span class="title">Notes</span>
        </td>
    </tr>
    <tr>
      <td><p>ViewState, in addition to managing state for server controls automatically,
          is a convenient place for ambient page state that needs to be maintained
          from request to request. In addition to storing primitive data types
          such as integers and strings, the <span class="literal">StateBag</span>
          class can be used to store objects, as long as those objects support
          serialization, as does the Color structure in the example. When you
          store an object that supports serialization in ViewState, the object's
          state is automatically serialized into a form that can be stored in
          ViewState and deserialized into an object instance when you reference
          the object again.</p>
        </td>
    </tr>
    <tr>
      <td colspan="2" class="clearseparation">&nbsp;</td>
    </tr>
    <tr>
      <td><p> Because ViewState does not store type information with the object,
          you must cast the object retrieved from ViewState to the correct type.
          In the case of the example, this type is System.Drawing.Color. Finally,
          think carefully before storing large objects (such as datasets) in ViewState.
          Because ViewState is stored as a hidden form field, it is sent to the
          browser with each request. Storing large objects in ViewState will result
          in slower page load times. </p></td>
    </tr>
  </table>
</div>
<div id="Controls">
  <table cellpadding="0" cellspacing="0" border="0" width="100%" class="main">
    <tr>
      <td valign="top" class="name">Controls</td>
      <td valign="top" nowrap class="compatibility"> </td>
    </tr>
    <tr>
      <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
    </tr>
    <tr>
      <td valign="top" class="usage" nowrap><p class="literal">ControlCollection = Page.Controls</p></td>
      <td valign="top" align="right">&nbsp;</td>
    </tr>
    <tr>
     <td colspan="2" class="clearseparation">&nbsp;</td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="description"><p>Provides access to the
          ControlCollection instance associated with the page, with which you
          can add or manipulate controls at runtime. </p></td>
    </tr>
    <tr>
      <td colspan="2" class="clearseparation">&nbsp;</td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="parameters"><span class="title">Parameters</span>
        <ul>
          <li><span class="literal">ControlCollection</span> <br>&nbsp;An object of type
            ControlCollection containing the controls associated with the page.
          </li>
        </ul></td>
    </tr>
    <tr>
      <td colspan="2" class="clearseparation">&nbsp;</td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="example"><span class="title">Example</span>
        </td>
    </tr>
    <tr>
      <td><p>The code example uses the Controls property to display the Count property
          of the<span class="literal"> ControlCollection</span> class instance
          associated with the page. It then adds a new Label control to the collection
          and displays the updated Count property by using the new label. </p><span class="programlisting">
          <pre>
Sub Page_Load( )
	Message.Text = &quot;There are currently &quot; &amp; Controls.Count &amp;_
		&quot; controls on the page.&lt;br/&gt;&quot;
	Dim Message2 As New Label
	Controls.AddAt(Controls.Count - 1, Message2)
	Message2.Text = &quot;There are now &quot; &amp; Controls.Count &amp;_
		&quot; controls on the page.&quot;
End Sub</pre></span></td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="notes"><span class="title">Notes</span>
        </td>
    </tr>
    <tr>
      <td><p>As with the Session and Trace properties, while you can retrieve a
          local reference to the Controls collection associated with the page,
          it is more common to access this instance directly through the Controls
          property, as shown in the example.</p>
        </td>
    </tr>
    <tr>
      <td colspan="2" class="clearseparation">&nbsp;</td>
    </tr>
    <tr>
      <td><p> Note that when adding a control to a page that already contains controls,
          using the AddAt method of the <span class="literal">ControlCollection</span>
          class allows more precise placement of the control when compared to
          the Add method, which simply places the control at the end of the collection.
          In the example, using the Add method would result in the output from
          the added Label control appearing after the page's closing <span class="literal">&lt;/html&gt;</span>
          tag, which is not well-formed HTML and could cause the page to render
          incorrectly in some browsers. </p></td>
    </tr>
  </table>
</div>
<div id="Validators">
  <table cellpadding="0" cellspacing="0" border="0" width="100%" class="main">
    <tr>
      <td valign="top" class="name">Validators</td>
      <td valign="top" nowrap class="compatibility"> </td>
    </tr>
    <tr>
      <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
    </tr>
    <tr>
      <td valign="top" class="usage" nowrap><p class="literal">ValidatorCollection =
          Page.Validators</p></td>
      <td valign="top" align="right">&nbsp;</td>
    </tr>
    <tr>
     <td colspan="2" class="clearseparation">&nbsp;</td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="description"><p>Returns an instance
          of the <span class="literal">ValidatorCollection</span> class containing
          all the validator controls contained on the requested page. We can access
          each validator control by iterating the ValidatorCollection collection.
        </p></td>
    </tr>
    <tr>
      <td colspan="2" class="clearseparation">&nbsp;</td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="parameters"><span class="title">Parameters</span>
        <ul>
          <li><span class="literal">ValidatorCollection</span> <br>&nbsp;An object variable
            of type ValidatorCollection.</li>
        </ul></td>
    </tr>
    <tr>
      <td colspan="2" class="clearseparation">&nbsp;</td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="example"><span class="title">Example</span>
        </td>
    </tr>
    <tr>
      <td><p>The code example displays a Textbox control with a RequiredFieldValidator
          and RegularExpressionValidator control assigned to it. In Page_Load,
          the code iterates through the ValidatorCollection returned by the Validators
          property and displays the ID and ErrorMessage property of each validator
          in the collection: </p><span class="programlisting">
          <pre>
&lt;%@ Page Language=&quot;vb&quot; %&gt;
&lt;html&gt;
	&lt;head&gt;
		&lt;title&gt;&lt;/title&gt;
		&lt;script runat=&quot;server&quot;&gt;
			Sub Page_Load( )
				Dim Validator as BaseValidator
				For Each Validator in Validators
					Message.Text &amp;= Validator.ID &amp; &quot; error message: &quot;
					Message.Text &amp;= Validator.ErrorMessage &amp; &quot;&lt;br/&gt;&quot;
				Next
			End Sub
		&lt;/script&gt;
	&lt;/head&gt;
&lt;body&gt;
	&lt;form runat=&quot;server&quot;&gt;
			Phone: &lt;asp:textbox id=&quot;phone&quot; runat=&quot;server&quot;/&gt;
			&lt;asp:requiredfieldvalidator
				id=&quot;rfvPhone&quot;
				controltovalidate=&quot;phone&quot;
				display=&quot;dynamic&quot;
				errormessage=&quot;Required!&quot;
				runat=&quot;server&quot;/&gt;
			&lt;asp:regularexpressionvalidator
				id=&quot;revPhone&quot;
				controltovalidate=&quot;phone&quot;
				display=&quot;dynamic&quot;
				validationexpression=&quot;^[2-9]\d{2}-\d{3}-\d{4}$&quot;
				errormessage=&quot;Enter a phone number in the form xxx-xxx-xxxx&quot;
				runat=&quot;server&quot;/&gt;
		&lt;br/&gt;
		&lt;asp:button id=&quot;submit&quot; text=&quot;Submit&quot; runat=&quot;server&quot;/&gt;
	&lt;/form&gt;
	&lt;br/&gt;
	&lt;asp:label id=&quot;Message&quot; runat=&quot;server&quot;/&gt;
&lt;/body&gt;
&lt;/html&gt;</pre></span></td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="notes"><span class="title">Notes</span>
        </td>
    </tr>
    <tr>
      <td><p>Because we are displaying only properties from the validator controls
          that are inherited from the BaseValidator control (from which all validation
          controls are derived), we don't need to cast the validator to its specific
          type before accessing the properties. If, however, we wanted to display
          a property that was specific to the type of validator used (such as
          the ValidationExpression property of the <span class="literal">RegularExpressionValidator</span>
          class), we would need to cast the control to the correct type. In Visual
          Basic .NET, this is done using the <span class="emphasis">CType</span> keyword. </p></td>
    </tr>
  </table>
</div>
<div id="DataBind">
  <table cellpadding="0" cellspacing="0" border="0" width="100%" class="main">
    <tr>
      <td valign="top" class="name">DataBind</td>
      <td valign="top" nowrap class="compatibility"> </td>
    </tr>
    <tr>
      <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
    </tr>
    <tr>
      <td valign="top" class="usage" nowrap><p class="literal">Page.DataBind( )</p></td>
      <td valign="top" align="right">&nbsp;</td>
    </tr>
    <tr>
      <td colspan="2" class="clearseparation">&nbsp;</td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="description"> <p>Evaluates and resolves
          any data binding expressions in the page. It also calls DataBind on
          all child controls. </p></td>
    </tr>
    <tr>
      <td colspan="2" class="clearseparation">&nbsp;</td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="parameters"><span class="title">Parameters</span>
        </td>
    </tr>
    <tr>
      <td><p> None </p></td>
    </tr>
    <tr>
      <td colspan="2" class="clearseparation">&nbsp;</td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="example"><span class="title">Example</span>
        </td>
    </tr>
    <tr>
      <td><p> The following code example uses a data binding expression to set the
          ForeColor attribute of a label control tag to the value of local variable
          named color. When the DataBind method is called in Page_Load, the value
          of the Color variable is assigned to the <span class="literal">ForeColor</span>
          attribute (which is effectively the same as setting the <span class="literal">ForeColor</span>
          property in code): </p><span class="programlisting">
          <pre>
&lt;%@ Page Language=&quot;vb&quot; %&gt;
&lt;html&gt;
	&lt;head&gt;
		&lt;title&gt;&lt;/title&gt;
		&lt;script runat=&quot;server&quot;&gt;
			Dim Color As System.Drawing.Color = System.Drawing.Color.Red
			Sub Page_Load( )
				Message.Text = &quot;ForeColor is: &quot; &amp; Color.Name DataBind( )
			End Sub
		&lt;/script&gt;
	&lt;/head&gt;
&lt;body&gt;
	&lt;asp:label id=&quot;Message&quot;ForeColor=&quot;&lt;%# Color %&gt;&quot;runat=&quot;server&quot;/&gt;
&lt;/body&gt;
&lt;/html&gt;</pre></span>
</td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="notes"><span class="title">Notes</span>
        </td>
    </tr>
    <tr>
      <td><p>If you want to perform data binding on a specific control on the page,
          such as a DataGrid or DataList control, it may be more efficient to
          call DataBind on that control rather than on the page, since calling
          it on the control will avoid any overhead in calling DataBind on controls
          for which data binding is not needed. </p></td>
    </tr>
  </table>
</div>
<div id="FindControl">
  <table cellpadding="0" cellspacing="0" border="0" width="100%" class="main">
    <tr>
      <td valign="top" class="name">FindControl</td>
      <td valign="top" nowrap class="compatibility"> </td>
    </tr>
    <tr>
      <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
    </tr>
    <tr>
      <td valign="top" class="usage" nowrap><p class="literal">Control = Page.FindControl(String)
        </p></td>
      <td valign="top" align="right">&nbsp;</td>
    </tr>
    <tr>
      <td colspan="2" class="clearseparation">&nbsp;</td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="description"> <p>Returns a reference
          to the control object whose name corresponds to a search string. The
          FindControl method is a member of the base <span class="literal">Control</span>
          class. </p></td>
    </tr>
    <tr>
      <td colspan="2" class="clearseparation">&nbsp;</td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="parameters"><span class="title">Parameters</span>
        <ul>
          <li><span class="literal">Control</span> <br>&nbsp;An instance of the <span class="literal">Control</span>
            class that represents the control that is found using the FindControl
            method. This control must be cast to the correct control type to access
            members that are specific to the control type. </li>
          <li><span class="literal">String</span> <br>&nbsp;A string containing the programmatic
            identifier of the control. This value is the same as the <span class="literal">ID</span>
            attribute of a declarative control, or in the case of controls created
            at runtime, is the same as the object name defined for the control.
          </li>
        </ul></td>
    </tr>
    <tr>
      <td colspan="2" class="clearseparation">&nbsp;</td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="example"><span class="title">Example</span>
        </td>
    </tr>
    <tr>
      <td><p>The example finds a control using its ID and changes its background
          color: </p><span class="programlisting">
          <pre>
Sub Page_Load( )
	Dim TheControl As Control = FindControl(&quot;Message&quot;)
	If Not TheControl Is Nothing Then
		Dim TheLabel As Label = CType(TheControl,Label)
		TheLabel.Text = &quot;Found the label named Message!&quot;
		TheLabel.BackColor = System.Drawing.Color.Blue
	End If
End Sub</pre></span></td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="notes"><span class="title">Notes</span>
        </td>
    </tr>
    <tr>
      <td><p>The FindControl method, which is inherited from the <span class="literal">Control</span>
          class (from which the <span class="literal">Page</span> class is derived),
          is useful when dealing with nested controls or user controls that need
          to manipulate a control in their parent page. For example, code in a
          user control could call FindControl on the page containing the user
          control to locate and manipulate a control contained within the page
          (but outside the user control). </p></td>
    </tr>
  </table>
</div>
<div id="HasControls">
  <table cellpadding="0" cellspacing="0" border="0" width="100%" class="main">
    <tr>
      <td valign="top" class="name">HasControls</td>
      <td valign="top" nowrap class="compatibility"> </td>
    </tr>
    <tr>
      <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
    </tr>
    <tr>
      <td valign="top" class="usage" nowrap><p class="literal">Boolean = Page.HasControls(
          )</p></td>
      <td valign="top" align="right">&nbsp;</td>
    </tr>
    <tr>
      <td colspan="2" class="clearseparation">&nbsp;</td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="description"> <p>Returns a Boolean value
          that indicates whether the page contains child controls. </p></td>
    </tr>
    <tr>
      <td colspan="2" class="clearseparation">&nbsp;</td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="parameters"><span class="title">Parameters</span>
        <ul>
          <li><span class="literal">Boolean</span> <br>&nbsp;A Boolean value that indicates
            whether the page contains child controls. </li>
        </ul></td>
    </tr>
    <tr>
      <td colspan="2" class="clearseparation">&nbsp;</td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="example"><span class="title">Example</span>
        </td>
    </tr>
    <tr>
      <td><p>The code example displays a message indicating whether the page has
          controls in its Controls collection, based on the value returned by
          HasControls: </p><span class="programlisting">
          <pre>
Sub Page_Load( )
	If Page.HasControls = True Then
		Message.Text = &quot;The page contains controls.&quot;
	Else
		Message.Text = &quot;The page does not contain controls.&quot;
	End If
End Sub</pre></span></td>
    </tr>
  </table>
</div>
<div id="LoadControl">
  <table cellpadding="0" cellspacing="0" border="0" width="100%" class="main">
    <tr>
      <td valign="top" class="name">LoadControl</td>
      <td valign="top" nowrap class="compatibility"> </td>
    </tr>
    <tr>
      <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
    </tr>
    <tr>
      <td valign="top" class="usage" nowrap><p class="literal">objControl = Page.LoadControl(strPath)
        </p></td>
      <td valign="top" align="right">&nbsp;</td>
    </tr>
    <tr>
      <td colspan="2" class="clearseparation">&nbsp;</td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="description"> <p>Returns an instance
          of the user control defined in the strPath user control file. This allows
          dynamic loading of user controls instead of using the <span class="literal">@
          Register</span> directive. </p></td>
    </tr>
    <tr>
      <td colspan="2" class="clearseparation">&nbsp;</td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="parameters"><span class="title">Parameters</span>
        <ul>
          <li><span class="literal">objControl</span> <br>&nbsp;An object of type Control
            that represents the user control specified in the given path. </li>
          <li><span class="literal">strPath</span> <br>&nbsp;The virtual path to a user
            control file.</li>
        </ul></td>
    </tr>
    <tr>
      <td colspan="2" class="clearseparation">&nbsp;</td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="example"><span class="title">Example</span>
        </td>
    </tr>
    <tr>
      <td><p>The example uses the LoadControl to load a user control at runtime
          and adds it to the page's Controls collection:</p><span class="programlisting">
	  <pre>
Sub Page_Load( )
	Dim Hello As UserControl = LoadControl(&quot;hello.ascx&quot;)
	Page.Controls.Add(Hello)
End Sub</pre></span>
</td>
    </tr>
    <tr>
      <td><p> The user control <span class="emphasis">hello.ascx</span>
          is as follows: </p><span class="programlisting">
          <pre>
&lt;h1&gt;Hello, World!&lt;/h1&gt;</pre></span></td>
    </tr>
  </table>
</div>
<div id="MapPath">
  <table cellpadding="0" cellspacing="0" border="0" width="100%" class="main">
    <tr>
      <td valign="top" class="name">MapPath</td>
      <td valign="top" nowrap class="compatibility"> </td>
    </tr>
    <tr>
      <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
    </tr>
    <tr>
      <td valign="top" class="usage" nowrap><p class="literal">String = Page.MapPath(virtualPath)
        </p></td>
      <td valign="top" align="right">&nbsp;</td>
    </tr>
    <tr>
      <td colspan="2" class="clearseparation">&nbsp;</td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="description"> <p>Returns the physical
          path that corresponds to a given virtual path. </p></td>
    </tr>
    <tr>
      <td colspan="2" class="clearseparation">&nbsp;</td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="parameters"><span class="title">Parameters</span>
        <ul>
          <li><span class="literal">String</span> <br>&nbsp;A String containing the physical
            path that corresponds to virtualPath.</li>
          <li><span class="literal">virtualPath</span> <br>&nbsp;A string containing an
            absolute or relative virtual path.</li>
        </ul></td>
    </tr>
    <tr>
      <td colspan="2" class="clearseparation">&nbsp;</td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="example"><span class="title">Example</span>
        </td>
    </tr>
    <tr>
      <td><p>The example maps the virtual path of the named page to its physical
          path: </p><span class="programlisting">
       <pre>
Sub Page_Load( )
	Message.Text = MapPath(&quot;MapPath.aspx&quot;)
End Sub</pre></span></td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="notes"><span class="title">Notes</span>
        </td>
    </tr>
    <tr>
      <td><p>The Page.MapPath method duplicates the functionality of the Server.MapPath
          method. </p></td>
    </tr>
  </table>
</div>
<div id="ResolveUrl">
  <table cellpadding="0" cellspacing="0" border="0" width="100%" class="main">
    <tr>
      <td valign="top" class="name">ResolveUrl</td>
      <td valign="top" nowrap class="compatibility"> </td>
    </tr>
    <tr>
      <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
    </tr>
    <tr>
      <td valign="top" class="usage" nowrap><p class="literal">String = Page.ResolveUrl(strRelativeUrl)
        </p></td>
      <td valign="top" align="right">&nbsp;</td>
    </tr>
    <tr>
      <td colspan="2" class="clearseparation">&nbsp;</td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="description"> <p>Returns an absolute
          URL corresponding to a relative URL. </p></td>
    </tr>
    <tr>
      <td colspan="2" class="clearseparation">&nbsp;</td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="parameters"><span class="title">Parameters</span>
        <ul>
          <li><span class="literal">String</span> <br>&nbsp;A string containing the absolute
            URL.</li>
          <li><span class="literal">strRelativeUrl</span> <br>&nbsp;A relative URL.</li>
        </ul></td>
    </tr>
    <tr>
      <td colspan="2" class="clearseparation">&nbsp;</td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="example"><span class="title">Example</span>
        </td>
    </tr>
    <tr>
      <td><p>The example maps the current relative URL to an absolute URL:</p><span class="programlisting">
          <pre>
Sub Page_Load( )
	Message.Text = Page.ResolveUrl(&quot;ResolveUrl.aspx&quot;)
End Sub</pre></span></td>
    </tr>
  </table>
</div>
<div id="Validate">
  <table cellpadding="0" cellspacing="0" border="0" width="100%" class="main">
    <tr>
      <td valign="top" class="name">Validate</td>
      <td valign="top" nowrap class="compatibility"> </td>
    </tr>
    <tr>
      <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
    </tr>
    <tr>
      <td valign="top" class="usage" nowrap><p class="literal">Page.Validate( )</p></td>
      <td valign="top" align="right">&nbsp;</td>
    </tr>
    <tr>
      <td colspan="2" class="clearseparation">&nbsp;</td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="description"> <p>Invokes the validation
          logic for each validator control on the page. When this method is invoked,
          it iterates the Page object's ValidatorCollection collection and executes
          the validation logic associated with each validator control. </p></td>
    </tr>
    <tr>
      <td colspan="2" class="clearseparation">&nbsp;</td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="example"><span class="title">Example</span>
        </td>
    </tr>
    <tr>
      <td><p>See the example for the IsValid property.
        </p></td>
    </tr>
    <tr>
      <td colspan="2" class="clearseparation">&nbsp;</td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="notes"><span class="title">Notes</span>
        </td>
    </tr>
    <tr>
      <td><p>The Validate method is called automatically when the user clicks any
          HTML or ASP button control whose CausesValidation property is <span class="literal">True</span>.
        </p></td>
    </tr>
  </table>
</div>
<div id="Error">
  <table cellpadding="0" cellspacing="0" border="0" width="100%" class="main">
    <tr>
      <td valign="top" class="name">Error</td>
      <td valign="top" nowrap class="compatibility"> </td>
    </tr>
    <tr>
      <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
    </tr>
    <tr>
      <td valign="top" class="usage" nowrap><p class="literal">Sub Page_Error(Sender
          As Object, e As EventArgs) 'error handling code <br>End Sub</p></td>
      <td valign="top" align="right">&nbsp;</td>
    </tr>
    <tr>
      <td colspan="2" class="clearseparation">&nbsp;</td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="description"> <br>The Error event is
          fired when an unhandled exception occurs on the page. If no event handler
          is defined for this event, the Application_Error event is fired. If
          the exception is still not handled, control is passed to the page (or
          pages) defined in the&lt;customErrors&gt; element&lt;customErrors&gt;
          element in <span class="emphasis">web.config</span>. </td>
    </tr>
    <tr>
      <td colspan="2" class="clearseparation">&nbsp;</td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="parameters"><span class="title">Parameters</span>
        <ul>
          <li><span class="literal">Sender</span> <br>&nbsp;An argument containing information
            about the object that raised the event. </li>
          <li><span class="literal">e</span> <br>&nbsp;An object of type EventArgs containing
            additional information about the event. </li>
        </ul></td>
    </tr>
    <tr>
      <td colspan="2" class="clearseparation">&nbsp;</td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="example"><span class="title">Example</span>
        </td>
    </tr>
    <tr>
      <td><p>The following code example deliberately causes an overflow exception
          and then handles that exception in the Page_Error handler, displaying
          the text of the exception and then clearing it: </p><span class="programlisting">
          <pre>
Sub Page_Load( )
	Dim x, y, overflow As Integer
	x = 1
	y = 0
	overflow = x / y
End Sub


Sub Page_Error( )
	Response.Write(Server.GetLastError.ToString())
	Server.ClearError
End Sub</pre></span></td>
    </tr>
     <tr>
      <td valign="top" colspan="2" class="notes"><span class="title">Notes</span>
        </td>
    </tr>
    <tr>
      <td><p>The current exception is obtained using the GetLastError method of
          the <span class="literal">Server</span> class. Once you've finished
          with your error handling, you can either clear the exception by calling
          Server.ClearError, as shown in the example, or allow the exception to
          bubble up to the next level of error handling. Note that the Sender
          and e arguments are optional for this event, as shown in the example.
          When the <span class="literal">AutoEventWireup</span> attribute of the
          <span class="literal">@ Page</span> directive is set to <span class="literal">True</span>
          (the default), ASP.NET will automatically call the event handler for
          this event, as long as it has the correct Page_Error signature.
        </p></td>
    </tr>
  </table>
</div>
<div id="Init">
  <table cellpadding="0" cellspacing="0" border="0" width="100%" class="main">
    <tr>
      <td valign="top" class="name">Init</td>
      <td valign="top" nowrap class="compatibility"> </td>
    </tr>
    <tr>
      <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
    </tr>
    <tr>
      <td valign="top" class="usage" nowrap><pre class="literal">
  Sub Page_Init(Sender As Object, e As EventArgs) 'initialization code
  End Sub</pre>
      <td valign="top" align="right">&nbsp;</td>
    </tr>
    <tr>
      <td colspan="2" class="clearseparation">&nbsp;</td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="parameters"><span class="title">Parameters</span>
        <ul>
          <li><span class="literal">Sender</span> <br>&nbsp;An argument containing information
            about the object that raised the event. </li>
          <li><span class="literal">e</span> <br>&nbsp;An object of type EventArgs containing
            additional information about the event. </li>
        </ul></td>
    </tr>
    <tr>
      <td colspan="2" class="clearseparation">&nbsp;</td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="example"><span class="title">Example</span>
        </td>
    </tr>
    <tr>
      <td><p>The code example initializes a variable for setting the ForeColor property
          of a label in Page_Init, and then modifies that value to set the ForeColor
          property of another label in Page_Load: </p><span class="programlisting">
          <pre>
&lt;%@ Page Language=&quot;vb&quot; %&gt;
&lt;html&gt;
	&lt;head&gt;
		&lt;title&gt; Init event example &lt;/title&gt;
		&lt;script runat=&quot;server&quot;&gt;
			Dim TheColor As System.Drawing.Color
			Sub Page_Init( )
				TheColor = System.Drawing.Color.Red
			End Sub
			Sub Page_Load( )
				Message.ForeColor = TheColor
				Message.Text = &quot;The color of the text was set in Page_Init.&quot;
				TheColor = System.Drawing.Color.Blue
				Message2.ForeColor = TheColor
				Message2.Text = &quot;The color of the text was set in Page_Load.&quot;
			End Sub
		&lt;/script&gt;
	&lt;/head&gt;
&lt;body&gt;
	&lt;asp:label id=&quot;Message&quot; runat=&quot;server&quot;/&gt;
	&lt;br/&gt;
	&lt;asp:label id=&quot;Message2&quot; runat=&quot;server&quot;/&gt;
&lt;/body&gt;
&lt;/html&gt;</pre></span></td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="notes"><span class="title">Notes</span>
        </td>
    </tr>
    <tr>
      <td><p>Note that the Sender and e arguments are optional for this event, as
          shown in the example. When the <span class="literal">AutoEventWireup</span>
          attribute of the <span class="literal">@ Page</span> directive is set
          to <span class="literal">True</span> (the default), ASP.NET will automatically
          call the event handler for this event, as long as it has the signature
          Page_Init. </p></td>
    </tr>
  </table>
</div>
<div id="Load">
  <table cellpadding="0" cellspacing="0" border="0" width="100%" class="main">
    <tr>
      <td valign="top" class="name">Load</td>
      <td valign="top" nowrap class="compatibility"> </td>
    </tr>
    <tr>
      <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
    </tr>
    <tr>
      <td valign="top" class="usage" nowrap><pre class="literal">
Sub Page_Load(Sender As Object, e As EventArgs) 'code
End Sub</pre>
     </td>
      <td valign="top" align="right">&nbsp;</td>
    </tr>
    <tr>
      <td colspan="2" class="clearseparation">&nbsp;</td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="description"> <br>Fired when the page
          is loaded. Since this event is fired on every page request, we can add
          any initialization code that needs to be executed at the page level,
          including the initialization of the page's child controls. When the
          Load event fires, the page's view state information is also accessible.

        </td>
    </tr>
    <tr>
      <td><p>The Load event is passed the following arguments by ASP.NET:</p>
        <ul>
          <li><span class="literal">Sender</span> <br>&nbsp;An argument containing information
            about the object that raised the event. </li>
          <li><span class="literal">e</span> <br>&nbsp;An object of type EventArgs containing
            additional information about the event.</li>
        </ul></td>
    </tr>
    <tr>
      <td colspan="2" class="clearseparation">&nbsp;</td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="example"><span class="title">Example</span>
        </td>
    </tr>
    <tr>
      <td><p>See the example for Init.
        </p></td>
    </tr>
    <tr>
      <td colspan="2" class="clearseparation">&nbsp;</td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="notes"><span class="title">Notes</span>
        </td>
    </tr>
    <tr>
      <td><p>Note that the Sender and e arguments are optional for this event, as
          shown in the example. When the <span class="literal">AutoEventWireup</span>
          attribute of the <span class="literal">@ Page</span> directive is set
          to <span class="literal">True</span> (the default), ASP.NET will automatically
          call the event handler for this event, as long as it has the correct
          Page_Load event signature. </p></td>
    </tr>
  </table>
</div>
<div id="Unload">
  <table cellpadding="0" cellspacing="0" border="0" width="100%" class="main">
    <tr>
      <td valign="top" class="name">Unload</td>
      <td valign="top" nowrap class="compatibility"> </td>
    </tr>
    <tr>
      <td colspan="2" class="divider"><img src="dwres:18084" width="100%" height="1"></td>
    </tr>
    <tr>
      <td valign="top" class="usage" nowrap><pre class="literal">
Sub Page_Unload(Sender As Object, e As EventArgs) 'cleanup code
End Sub	</pre>
	</td>
      <td valign="top" align="right">&nbsp;</td>
    </tr>
    <tr>
      <td colspan="2" class="clearseparation">&nbsp;</td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="description"> <br>Fired when the page
          is unloaded from memory. Since this event is fired before the page is
          unloaded, we can perform cleanup operations, such as closing open files
          and database connections.
        </td>
    </tr>
    <tr>
      <td><p>The Unload event is passed the following arguments by ASP.NET:</p>
        <ul>
          <li><span class="literal">Sender</span> <br>&nbsp;An argument containing information
            about the object that raised the event. </li>
          <li><span class="literal">e</span> <br>&nbsp;An object of type EventArgs containing
            additional information about the event.</li>
        </ul></td>
    </tr>
    <tr>
      <td colspan="2" class="clearseparation">&nbsp;</td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="example"><span class="title">Example</span>
        </td>
    </tr>
    <tr>
      <td><p>The example demonstrates the Unload event by closing a file that was
          opened for display in the Page_Load event handler: </p><span class="programlisting">
          <pre>
Dim TheFile As System.IO.StreamReader
Sub Page_Load( )
	TheFile = System.IO.File.OpenText(MapPath(&quot;Init.aspx&quot;))
	Message.Text = &quot;&lt;pre&gt;&quot; &amp;_
		Server.HtmlEncode(TheFile.ReadToEnd()) &amp; &quot; &lt;/pre&gt;&quot;
End Sub

Sub Page_Unload( )
	TheFile.Close( )
End Sub</pre></span></td>
    </tr>
    <tr>
      <td valign="top" colspan="2" class="notes"><span class="title">Notes</span>
        </td>
    </tr>
    <tr>
      <td><p>While the Unload event is useful for performing page-level cleanup
          tasks, for resources such as databases, for which it is possible that
          an exception will interrupt the normal flow of page processing, it may
          be better to place the cleanup code for that resource in the Finally
          block of a <span class="literal">Try...Catch...Finally</span> statement,
          which will ensure that the cleanup code is always executed. For more
          information on <span class="literal">Try...Catch...Finally</span>, see
          Chapter 10. Note that the Sender and e arguments are optional for this
          event, as shown in the example. When the<span class="literal">AutoEventWireup</span>
          attribute of the <span class="literal">@ Page</span> directive is set
          to <span class="literal">True</span> (the default), ASP.NET will automatically
          call the event handler for this event, as long as it has the signature
          Page_Unload. </p></td>
    </tr>
  </table>
</div>
</body>
</html>
