Easy Tutorial
❮ Prop Webcontrol Table Backimageurl Prop Webcontrol Radiobuttonlist Textalign ❯

ASP.NET Web Forms - HTML Pages


A simple ASP.NET page looks just like a regular HTML page.


Hello tutorialpro.org

Before we start learning ASP.NET, let's build a simple HTML page that will display "Hello tutorialpro.org" in the browser:

| Hello tutorialpro.org! |


Hello tutorialpro.org Written in HTML

The following code will display the example as an HTML page:

If you want to try it yourself, save the above code to a file named "firstpage.htm" and create a link to it: firstpage.htm.


Hello tutorialpro.org Written in ASP.NET

The easiest way to convert an HTML page to an ASP.NET page is to simply copy an HTML file and change the extension of the new file to .aspx.

The following code will display the example as an ASP.NET page:

If you want to try it yourself, save the above code to a file named "firstpage.aspx" and create a link to it: firstpage.aspx.


How Does It Work?

Fundamentally, an ASP.NET page is identical to an HTML page.

An HTML page has the extension .htm. If a browser requests an HTML page from the server, the server can send the page directly to the browser without any modifications.

An ASP.NET page has the extension .aspx. If a browser requests an ASP.NET page from the server, the server needs to process any executable code in the page before sending the result back to the browser.

The above ASP.NET page does not contain any executable code, so nothing is executed. In the following example, we will add some executable code to the page to demonstrate the difference between a static HTML page and a dynamic ASP page.


Classic ASP

Active Server Pages (ASP) has been popular for many years. With ASP, executable code can be placed in an HTML page.

The earlier versions of ASP (before ASP.NET) are often referred to as Classic ASP.

ASP.NET is not fully compatible with Classic ASP, but most Classic ASP pages can run well as ASP.NET pages with only minor modifications.

If you want to learn more about Classic ASP, visit our ASP Tutorial.


Dynamic Page Written in Classic ASP

To demonstrate how ASP displays pages with dynamic content, we will add some executable code (highlighted in red) to the above example: <%Response.Write(now())%>

The code within the <% --%> tags is executed on the server.

Response.Write is ASP code used to write something to the HTML output stream.

Now() is a function that returns the current date and time of the server.

If you want to try it yourself, save the above code to a file named "dynpage.asp" and create a link to it: dynpage.asp.


Dynamic Page Written in ASP.NET

The following code will display the example as an ASP.NET page: <%Response.Write(now())%>

If you want to try it yourself, save the above code to a file named "dynpage.aspx" and create a link to it: dynpage.aspx.


ASP.NET vs. Classic ASP

The above example does not demonstrate any differences between ASP.NET and Classic ASP.

As in the last two examples, you cannot see any differences between an ASP page and an ASP.NET page.

In the next chapter, you will see how server controls make ASP.NET more powerful than Classic ASP.

❮ Prop Webcontrol Table Backimageurl Prop Webcontrol Radiobuttonlist Textalign ❯