
32
|
Chapter 3: Web Forms
This is the Title of the Book, eMatter Edition
Copyright © 2008 O’Reilly & Associates, Inc. All rights reserved.
Server-side comments
As always, comments are used for documentation and testing purposes. You
can use them to prevent any code from executing, as in the following
example:
<%-- Debugging Code To Be Removed --%>
Server controls
HTML and web controls declared with the
runat="server" attribute/value
pair. For example, the following code declares an HTML input server control
and an ASP TextBox control:
<input type="text" id="MyText" runat="server">
<asp:TextBox id="Mytext" runat="server"/>
Server-side object tags
Used to declare and instantiate classic COM components and .NET classes.
For example:
<object id="MyDataSet" class="System.Data.DataSet" runat="server">
Server-side include directives
Used to include any text file into your page. This was the primary code reuse
mechanism in classic ASP. For example:
<!-- #Include file="TopNavigation.inc" -- >
<!-- #Include virtual="Menus.inc" -- >
In ASP.NET, the preferred means of sharing code is to create a shared class or
server control that contains the functionality to be reused.
Server-side <form> element
Many server controls, including the TextBox control, must be contained
within a server-side
<form> tag pair with the runat="server" attribute:
<form runat="server">
<asp:TextBox id="Mytext" runat="server"/>
<asp:Button id="submit" ...