ASP.NET is immediately tutorial 2

xiaoxiao2021-03-05  25

What is asp.net Web Forms

ASP.NET Web Forms Page Frame is an upgraded general language runtime (CLR) program model for servers

Dynamically generate web pages. (Americans talking is awkward, in fact, Web Forms is the page written by ASP.NET)

As the rational evolution of ASP (ASP.NET provides grammatical compatibility with existing ASP), setting up the ASP.NET Web Forms framework

The eye is used to solve the shortcomings of the ASP mode. It provides:

· Create and use reusable user interface controls, packaging common functions, reduce page developers writing code

the amount.

· Provide developers with clear structure, well-plated page logic (rather than "Italian noodles").

· Provide a powerful page development tool (Wysiwyg) (ASP code is opaque for tools)

This part of this textbook provides a high level of code that makes a preliminary interface for the key features of ASP.NET Web Forms.

Shao. Subsequent chapters will analyze the function of ASP.NET Web Forms more deeply.

Writing the first Web Forms page

The ASP.NET Web Forms page is a text file that is an extension in ASPX. They can pass the IIS virtual root directory tree

Configure. When the browser client requests .a, the ASP.NET runtime library analysis and compiling the target text

Parts, formation .NET frameworks. This class can be used to dynamically process the upcoming request. (Note: .aspx file only

There is compiled time when you are accessed; compiled results are repeated in future requests).

You can easily change the extension of the HTML file to ASPX, giving an ASP.NET file (no need to modify any generation

code). For example, the following example demonstrates an HTML page, which collects the user's name and classification preference, then press

Submit the form when the button is made.

C # intro1.aspx

[Run] | [Source]

Important: Note that nothing will happen when you click the Lookup button. This is because .aspx files only contain quiet

HTML (no dynamic content). Therefore, the same HTML will return to the time of each round trip

The content of the client and the form is lost during the submission process.

Quote sign using ASP

ASP.NET provides syntax compatibility with existing ASP pages. This compatibility includes code reference blocks, in the .aspx file

It can be used with HTML content. These code blocks are executed from the top of the quote.

The following example demonstrates how to use the reference flag in the HTML block (increasing the font size in turn)

C # INTRO2.ASPX

[Run] | [Source]

Important: Unlike ASP, the code used in the above block is really compiled, not the solution of the script engine.

Release execution. Therefore, it is improved in operational efficiency.

ASP.NET page developers can use the code block dynamically modify the output of HTML, just like using ASP. E.g

The following example demonstrates how to use the results that implement the response client submit.

C # intro3.aspx

[Run] | [Source]

Important: The code block provides a powerful way to customize and operate text from the ASP.NET page.

Output, however, but does not provide a clear programming program mode. As the example above, the developer only uses a generation

The code block must be sent in the request to send a round trip, the page status is managed, and the value is managed later.

ASP.NET Server Control Introduction

In addition to using (or as an instead) to scrubb, ASP.NET page developers can use the ASP.NET server control to design web page programs. When declaring the server space in the .aspx file,

Use the ASP.NET-specific tag or use the HTML tag containing the runat = "server" property. HTML label as control

The case of use is defined in the namespace system.web.ui.htmlControls. Anything that cannot be mapped to the control

The label is assigned to System.Web.ui.htmlControls.htmlGenericControl type.

The following example uses four server controls:

,

, , with . At the time of operation, this

Some server controls generate HTML content.

C # Intro4.aspx

[Run] | [Source]

Important: Rount Trips ----- I don't know how accurate translation of the cyclic round trips

Word, what he means to submit data from the client to the server, then return from the server to the process of data)

These server controls automatically keep the value entered by any client (it replaces the cyclic round trip, the form is single-character

There is a practice. Also note that you don't need any guests in ASP.NET.

Household script support

In addition to supporting standard HTML input controls, ASP.NET allows developers to use a richer custom control in the page.

For example, the following example demonstrates how to use controls on the page to implement dynamic rotational ads.

C # intro5.aspx

[Run] | [Source]

Important: All built-in server controls are available in the Web Forms Control Reference section of this tutorial.

========== to be continued. . .

转载请注明原文地址:https://www.9cbs.com/read-35515.html

New Post(0)