A brief overview of the ASP.net 2.0 page framework

Source: Internet
Author: User
Tags html page

The ASP.net Web Forms page Frame component is a scalable common language runtime programming model that can be used to dynamically generate Web pages. Asp. NET page framework component is the rational evolution of the ASP (the syntax provided by ASP.net is compatible with existing pages) and is deliberately designed to address a large number of critical flaws in the early model. In particular, it provides the ability to build and use reusable (reusable) UI controls that encapsulate common functionality, reducing the amount of code that page developers need to write; It enables developers to construct page logic (not "wrapped Code") in a clear and orderly manner. The development tools it uses provide powerful WYSIWYG (WYSIWYG) page design support capabilities (existing traditional ASP code is opaque). This article introduces some basic knowledge of ASP.net page features.

Write the first asp.net page

Asp. NET page is a text file with an. aspx extension. The page consists of code and tags (tag) that are dynamically compiled and executed on the server, generating display content for the requesting client browser (or device). They can be deployed under the IIS Virtual directory tree. When the browser client requests an. aspx resource, the ASP.net runtime (runtime) analyzes the target file and compiles it into a. NET Framework class, which can then be used to process requests dynamically (note that. aspx files are compiled only the first time they are accessed, and the resulting type instances are compiled for Multiple requests are reused).

We don't have to change the code in the HTML file, we just need to change its extension to. aspx and we have a asp.net page. For example, the following example shows a simple HTML page that collects the user's name and category and sends the form back to the original page when the user clicks the button:

<form action="intro1_vb.aspx" method="post">
<h3> Name: <input id="Name" type=text>
Category: <select id="Category" size=1>
<option>psychology</option>
<option>business</option>
<option>popular_comp</option>
</select>
<input type=submit value="Lookup">
</h3>
</form>

Please note that nothing happens when you click the "Lookup" button, because the. aspx file contains only static HTML (no dynamic content). As a result, the same HTML is sent back to the client, causing the contents of the Form field (text box and Drop-down list) to be lost.

Add simple code to a page

Asp. NET provides syntax that is compatible with ASP pages. It supports <%%> code rendering (render) blocks, which can be mixed with HTML content in an. aspx file. These blocks of code are strictly executed when the page is displayed.

The following example shows how to use <%%> render blocks in HTML (each time you increase the size of the font):

<form action="intro2_vb.aspx" method="post">
<h3> Name: <input id="Name" type=text>
Category: <select id="Category" size=1>
<option>psychology</option>
<option>business</option>
<option>popular_comp</option>
</select>
</h3>
<input type=submit value="Lookup">
<p>
<% Dim I As Integer
For I = 0 to 7 %>
<font size="<%=I%>"> Welcome to ASP.NET </font> <br>
<% Next %>
</form>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.