Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the concept of ASP.NET page framework

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains "what is the concept of ASP.NET page framework". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Next let the editor to take you to learn "what is the concept of ASP.NET page framework"!

The ASP.NET page framework component is a scalable universal language runtime programming model in the Web forms framework, which can be used to generate Web pages dynamically. The ASP.NET page framework component is a rational evolution of ASP (the syntax provided by ASP.NET is compatible with existing pages) and is specifically designed to address a large number of key flaws in early models. In particular, it provides the ability to create and use reusable UI controls that encapsulate common functions, thereby reducing the amount of code that page developers need to write; it enables developers to construct page logic (not "intertwined code") in a clear and orderly manner. The development tools it uses provide powerful WYSIWYG (WYSIWYG) page design support (existing traditional ASP code is opaque).

Write * ASP.NET pages

An ASP.NET page is a text file with an .aspx extension. The page consists of code and tags (tag) that are compiled and executed dynamically on the server to generate display content for the requesting client browser (or device). They can be deployed under the IIS virtual directory tree. When the browser client requests .aspx resources, the ASP.NET runtime (runtime) parses the object 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 when they are accessed *, and the resulting type instances are later reused by multiple requests).

Instead of modifying the code in the HTML file, we just need to change its extension to .aspx to create an ASP.NET page. For example, the following example demonstrates 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" > < h4 > 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" > < / h4 > < / form >

Please note that nothing happens when you click the "Lookup" button, because the .aspx file contains only static HTML (no dynamic content). Therefore, the same HTML is sent back to the client, resulting in the loss of the contents of the form fields (text boxes and drop-down lists).

Add simple code to the page

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

The following example shows how to use the <%% > rendering block in HTML (increasing the font size each time):

< form action= "intro2_vb.aspx" method= "post" > < h4 > Name: < input id= "Name" type=text > Category: < select id= "Category" size=1 > < option > psychology < / option > < option > business < / option > < option > popular_comp < / option > < / select > < / h4 > < 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 >

Note that the <% > code block in the above example is different from ASP in that it is actually compiled-- not interpreted by the script engine. This improves the execution performance of the runtime.

ASP.NET page framework developers can use the <% > code block to dynamically modify HTML output information. For example, the following code demonstrates how to use the <% > code block to interpret the results sent back by the client:

< form action= "intro3_vb.aspx" > < h4 > Name: < input name= "Name" type=text value= "<% = HttpUtility.HtmlEncode (Request.QueryString (" Name "))% >" > Category: < select name= "Category" size=1 > <% Dim I As Integer Dim Values (2) As String Values (0) = "psychology" Values (1) = "business" Values (2) = "popular_comp" For I = 0 To Values.Length-1 < If (Request.QueryString ("Category") = Values (I)) > < option selected > < Else > < option > < End If > <% = Values (I) > < / option > < Next > < / select > < / h4 > < input type=submit name= "Lookup" value= "Lookup" < p > < If (Not Request.QueryString ("Lookup") = Nothing) > Hi < % = HttpUtility.HtmlEncode (Request.QueryString ("Name"))% > You selected: <% = HttpUtility.HtmlEncode (Request.QueryString ("Category"))% > <% End If% > < / form >

Note that although <%% > code blocks provide a powerful way for us to customize the text output information returned by ASP.NET pages, they do not provide a clear HTML programming model. The above example shows that developers who only use the <%% > code block must manage the status of the page and intercept the values sent by themselves.

At this point, I believe you have a deeper understanding of "what is the concept of ASP.NET page framework". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report