ASP.NET Page Structure

List of important components of an ASP.NET Page: 

i) Directives

ii) Code Declaration Blocks

iii) Code Render Blocks

iv) Server Side Comments

v) Server Side Include Directives

vi) Literal Text and HTML Tags


i) Directives

It controls how an ASP.NET page is compiled. It starts with <%a and the end of a directive is marked with %>.  And by convention, a directive typically appears at the top of an ASP.NET page. And it can also appear anywhere on a page.

There are many types of directives that we can add to an ASP.NET page. But the most useful types of directives are:

i) Page

ii) Import

This section contains the <%@ Page %> directive that defines attributes of the page such as the language, code-behind file, and master page.


ii) Code Declaration Blocks

A code declaration block contains all the application logic for an ASP.NET page and it also includes global variable and functions declarations. And it must appear within the script runat= "server" tag.


iii) Code Render Blocks

If you want to execute code within HTML, then you can include the code within code render blocks. There are mainly two types of blocks:

• Inline Code: The inline code executes a statement or a series of statements. And it is marked by the characters <% and %>.

• Inline Expressions: These are used to display the value of a variable or a method. And these can be considered as a shorthand notation for the Response. And these are marked by the characters <%= and %>.


iv) Server-Side Comments

If you want to add comments to ASP.NET pages then you can add by using server-side comment blocks. The comments are added to a page to document. You cannot see the content on the Web Browser which content is within the server-side tags.

If you are a developer so these comments are very useful for you when you are debugging your ASP.NET pages. The starting of server-side comments is marked with the characters <%-- and the ending of the comments is marked with --%>.


v) Server Side Include Directives

If we want to include a file in an ASP.NET page then we can include using the server-side include directive.  And it is executed before any of the code that is in the page. And we can also specify the virtual path of the file. We can include server-side directives using the following directive: 

<!-- #INCLUDE file="includefile.aspx" -->

These properties determine the location of grid items that where to start the item.


vi) Literal Text and HTML Tags

This is the final type of element it is that we can also include HTML content in an ASP.NET page. The static pages of our application are built with plain HTML tags and text.

And the HTML content in a page is represented with the LiteralControl class. And we can also use the Text property of the LiteralControl class to manipulate the pure HTML portion of an ASP.NET page.

Tags

Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.

Top Post Ad

Below Post Ad