Latest web development tutorials

ASP.NET Web pages

Simple ASP.NET page looks like normal HTML pages.


Hello W3CSchool.cc

Before starting to learn ASP.NET, let's build a simple HTML page that displays "Hello W3CSchool.cc" in the browser:

Hello W3CSchool.cc!



Written in HTML Hello W3CSchool.cc

The following code will be in the form of HTML pages Display example:

<html>
<body bgcolor="yellow">
<center>
<h2>Hello W3CSchool.cc!</h2>
</center>
</body>
</html>

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


Written in ASP.NET Hello W3CSchool.cc

ASP.NET pages easiest way to convert HTML pages to be copied directly an HTML file and the new file extension changed to.aspx.

The following code will display examples form ASP.NET page:

<html>
<body bgcolor="yellow">
<center>
<h2>Hello W3CSchool.cc!</h2>
</center>
</body>
</html>

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


How does it work?

Fundamentally, ASP.NET and HTML pages are identical.

Extension of HTML page is .htm. If a browser requests an HTML page to the server, the server can not make any changes, it is sent directly to the browser page.

Extension ASP.NET page is .aspx. If a browser requests to the server an ASP.NET page, the server before the results are sent back to the browser, the page will need to deal with the executable code.

ASP.NET page above does not contain any executable code, so do not execute anything. In the following example, we will add some executable code to the page in order to demonstrate differences between static HTML pages and dynamic ASP pages at.


Classic ASP

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

Previous versions of ASP (before ASP.NET) is often called classic ASP.

ASP.NET is not fully compatible with classic ASP, but only after minor modifications, most classic ASP pages ASP.NET pages can serve as a good run.

If you want to learn more about classic ASP knowledge, please visit our ASP tutorial .


Prepared with classic ASP dynamic pages

To demonstrate how ASP display dynamic content pages, we will add some executable code (in red font identity) above examples:

<html>
<body bgcolor="yellow">
<center>
<h2>Hello W3CSchool.cc!</h2>
<p> <%Response.Write(now())%> </p>
</center>
</body>
</html>

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

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

Now () is a server returns the current date and time functions.

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


With dynamic pages written in ASP .NET

The following code will display examples form ASP.NET page:

<html>
<body bgcolor="yellow">
<center>
<h2>Hello W3CSchool.cc!</h2>
<p> <%Response.Write(now())%> </p>
</center>
</body>
</html>

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


ASP.NET Classic ASP comparison

Examples of the above can not demonstrate any differences between ASP.NET and classic ASP.

As the last two instances, you can not see the difference between the two ASP and ASP.NET pages between pages.

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