====== Tag Syntax Reference ======
===== ASP.NET Web Forms Syntax Elements =====
An ASP.NET Web Forms page is a declarative text file with an .aspx file name extension. In addition to static content, you can use eight distinct syntax markup elements. This section of the QuickStart reviews each of these syntax elements and provides examples demonstrating their use.
===== Rendering Code Syntax: <% %> and <%= %> =====
Code rendering blocks are denoted with <% ... %> elements, allow you to custom-control content emission, and execute during the render phase of Web Forms page execution. The following example demonstrates how you can use them to loop over HTML content.
<% For I=0 To 7 %>
Hello World!
<% Next %>
===== Declaration Code Syntax:
<%
...
number = subtract(number, 1)
...
%>
===== ASP.NET Server Control Syntax =====
Custom ASP.NET server controls enable page developers to dynamically generate HTML user interface (UI) and respond to client requests. They are represented within a file using a declarative, tag-based syntax. These tags are distinguished from other tags because they contain a "runat=server" attribute. The following example demonstrates how an server control can be used within an ASP.NET page. This control corresponds to the Label class in the System.Web.UI.WebControls namespace, which is included by default.
By adding a tag with the ID "Message", an instance of Label is created at run time:
The control can then be accessed using the same name. The following line sets the Text property of the control.
Message.Text = "Welcome to ASP.NET"
===== ASP.NET HTML Server Control Syntax =====
HTML server controls enable page developers to programmatically manipulate HTML elements within a page. An HTML server control tag is distinguished from client HTML elements by means of a "runat=server" attribute. The following example demonstrates how an HTML server control can be used within an ASP.NET page.
As with other server controls, the methods and properties are accessible programmatically, as shown in the following example.
...
===== Data Binding Syntax: <%# %> =====
The data binding support built into ASP.NET enables page developers to hierarchically bind control properties to data container values. Code located within a <%# %> code block is only executed when the DataBind method of its parent control container is invoked. The following example demonstrates how to use the data binding syntax within an control.
Within the datalist, the template for one item is specified. The content of the item template is specified using a data binding expression and the Container.DataItem refers to the data source used by the datalist MyList.
Here is a value: <%# Container.DataItem %>
In this case the data source of the MyList control is set programmatically, and then DataBind() is called.
Sub Page_Load(sender As Object, e As EventArgs)
Dim items As New ArrayList()
items.Add("One")
items.Add("Two")
items.Add("Three")
MyList.DataSource = items
MyList.DataBind()
End Sub
===== Object Tag Syntax: =====
Object tags enable page developers to declare and create instances of variables using a declarative, tag-based syntax. The following example demonstrates how the object tag can be used to create an instance of an ArrayList class.
The object will be created automatically at run time and can then be accessed through the ID "items".
Sub Page_Load(sender As Object, e As EventArgs)
items.Add("One")
items.Add("Two")
items.Add("Three")
...
End Sub
===== Server-Side Comment Syntax: <%-- Comment --%> =====
Server-side comments enable page developers to prevent server code (including server controls) and static content from executing or rendering. The following sample demonstrates how to block content from executing and being sent down to a client. Note that everything between <%-- and --%> is filtered out and only visible in the original server file, even though it contains other ASP.NET directives.
<%--
<% For I=0 To 44 %>
Hello World
<% Next %>
--%>
===== Server-Side Include Syntax: <-- #Include File="Locaton.inc" --> =====
Server-side #Includes enable developers to insert the raw contents of a specified file anywhere within an ASP.NET page. The following sample demonstrates how to insert a custom header and footer within a page.
...
===== Page Declaration =====
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="WebPageSeparated.aspx.vb Inherits="WebPageSeparated" %>
* **Language**
* the language used in the page
* **AutoEventWireup**
* FIXME
* **CodeFile**
* the optional filename containing the programming code, if you want code separated from web page design
* **Inherits**
* FIXME