ASP.NET Page Structure

You are now in a position to examine the formal structure of an ASP.NET page. The following is a list of the important elements of an ASP.NET page:
* Directives
* Code declaration blocks
* ASP.NET controls
* Code render blocks
* Server-side comments
* Server-side include directives
* Literal text and HTML tags

Each element is discussed in the following sections.
Directives
A directive controls how an ASP.NET page is compiled. The beginning of a directive is marked with the characters <%@ and the end of a directive is marked with the characters %>. A directive can appear anywhere within a page. By convention, however, a directive typically appears at the top of an ASP.NET page.

There are several types of directives that you can add to an ASP.NET page. Two of the most useful types are page and import directives.
Page Directives

You can use a page directive to specify the default programming language for a page. Page directives can also be used to enable tracing and debugging for a page.

To change the default programming language of an ASP.NET page from Visual Basic to C#, for example, you would use the following page directive:

<%@ Page Language="C#" %>

NOTE

The keyword Page in a page directive is optional. The following two directives are equivalent:

<%@ Page Language="C#" %>
<%@ Language="C#" %>

Another extremely useful page directive is the Trace directive. If you enable tracing for a page, additional information about the execution of the page is displayed along with the content of the page.You can enable tracing for a page by including the following directive:

<%@ Page Trace="True" %>

After you enable tracing for a page, you can display trace messages by using two methods of the Trace class: Write() and Warn(). You can use either method to display a custom message in the trace information displayed at the bottom of the page. The only difference between the two methods is that the former method displays messages in black text, and the latter method displays messages in red text, which is easier to see.
The ASP.NET page in Listing 11 uses these methods to display various trace messages.

Postingan populer dari blog ini

vb6 msflexgrid

Tutorial Visual Basic 6.0 : Listbox in VB6

Select Single Cell in MSHFlexgrid