Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

ASP.NET web page


May 12, 2021 ASP.NET


Table of contents


ASP.NET Web Forms - HTML page

This section explains ASP.NET the writing of the page and make a simple comparison with the writing of the HTML page.

Simple ASP.NET page looks like a normal HTML page.


Hello w3cschool.cn

Before we ASP.NET, let's build a simple HTML page that will display "Hello w3cschool.cn":

Hello w3cschool.cn!



Hello videos written in HTML w3cschool.cn

The following code displays the instance as an HTML page:

<html>
<body bgcolor="yellow">
<center>
<h2>Hello w3cschool.cn!</h2>
</center>
</body>
</html>

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


Hello ASP.NET written in w3cschool.cn

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

The following code displays ASP.NET as a page:

<html>
<body bgcolor="yellow">
<center>
<h2>Hello w3cschool.cn!</h2>
</center>
</body>
</html>

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


How does it work?

Basically, the ASP.NET page is exactly the same as HTML.

The extension of the HTML page is .htm. If the browser requests an HTML page from the server, the server can send the page directly to the browser without any modifications.

ASP.NET the extension of the page is .aspx. If the browser requests an ASP.NET page from the server, the server needs to process the executable code on the page before sending the results back to the browser.

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


Classic ASP

Active Server Pages (ASP) has been popular for many years. With ASP, you can place executable code in HTML pages.

Previous ASP versions (before ASP.NET) are often referred to as classic ASPs.

ASP.NET is not fully compatible with classic ASPs, but with only minor modifications, most classic ASP pages work well as ASP.NET pages.

If you would like to learn more about classic ASPs, please visit our ASP tutorial.


Dynamic pages written with classic ASPs

To demonstrate how the ASP displays pages that contain dynamic content, we'll add some executable code (red font identification) to the instance above:

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

The code within the label is executed on the server.

Response.Write is ASP code that is used to write to html output streams.

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

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


Dynamic pages written with ASP .NET

The following code displays ASP.NET as a page:

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

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


ASP.NET compare classic ASPs

The above example does not demonstrate any ASP.NET between the model and the classic ASP.

As in the last two instances, you don't see the difference between an ASP ASP.NET and an ASP page.

In the next chapter, you'll see how server controls make ASP.NET more powerful than a classic ASP.

Related tutorials

HTML tutorial