May 12, 2021 ASP.NET
1. ASP.NET Web Forms - HTML page
4. Hello videos written in HTML w3cschool.cn
5. Hello ASP.NET written in w3cschool.cn
8. Dynamic pages written with classic ASPs
9. Dynamic pages written with ASP .NET
Simple ASP.NET page looks like a normal HTML page.
Before we ASP.NET, let's build a simple HTML page that will display "Hello w3cschool.cn":
Hello w3cschool.cn! |
The following code displays the instance as an HTML page:
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.
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:
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.
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.
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.
To demonstrate how the ASP displays pages that contain dynamic content, we'll add some executable code (red font identification) to the instance above:
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.
The following code displays ASP.NET as a page:
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.
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.