Wednesday, February 8, 2012


The Structure of an ASP.NET Page

The following is a list of the important elements of an ASP.NET page:
1. Directives
2. Code declaration blocks
3. ASP.NET controls
4. Code render blocks
5. Server-side comments
6. Server-side include directives
7. Literal text and HTML tags
1. 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 Language="VB" %>
Import Directives
By default, only certain namespaces are automatically imported into an ASP.NET page. If you want to refer to a class that
isn't a member of one of the default namespaces, then you must explicitly import the namespace of the class.
<%@ Import Namespace="System.Web.Mail" %>

2. Code Declaration Blocks
A code declaration block contains all the application logic for your ASP.NET page and all the global variable declarations,
subroutines, and functions. It must appear within a
3. ASP.NET Controls
ASP.NET controls can be freely placed with the text and HTML content of a page. The only requirement is that the controls
should appear within a
tag.
One significant limitation of ASP.NET pages is that they can contain only one tag. This
means that you cannot group ASP.NET into multiple forms on a page. If you try, you get an error.
4. Code Render Blocks
If you need to execute code within the HTML or text content of your ASP.NET page, you can do so within code render
blocks. The two types of code render blocks are inline code and inline expressions. Inline code executes a statement or series
of statements. This type of code begins with the characters <% and ends with the characters %>.
Inline expressions, on the other hand, display the value of a variable or method (this type of code is shorthand for
Response.Write). Inline expressions begin with the characters <%= and end with the characters %>.
Inline expressions, on the other hand, display the value of a variable or method (this type of code is shorthand for
Response.Write). Inline expressions begin with the characters <%= and end with the characters %>.
5. Server-side Comments
You can add comments to your ASP.NET pages by using server-side comment blocks. The beginning of a server-side
comment is marked with the characters <%-- and the end of the comment is marked with the characters --%>.
6. Server-side Include Directives
You can include a file in an ASP.NET page by using one of the two forms of the server-side include directive. If you want
to include a file that is located in the same directory or in a subdirectory of the page including the file, you would use the
following directive:
7. Literal Text and HTML Tags
The final type of element that you can include in an ASP.NET page is HTML content. The static portion of your page is built
with plain old HTML tags and text.

0 comments:

Post a Comment

Followers

 

Teaching Dot Net. Copyright 2012 All Rights Reserved

Managed By Abhishek Pathak