Asp. NET introductory thoughts of my Heart

Source: Internet
Author: User
Tags manual final html page http request interface net client
asp.net a group of people who speak the same language, plan to build a towering tower to reach the heavens, to prove the strength of ethnic unity, the tower will soon take shape. This may disturb the heavenly God, he thought that this person and the God all become the neighbor, how still to rule the human? So the magic disturbed people's language, so that they can not communicate, so the tower can no longer continue to build.

Plainly my heart-human-computer Interaction (Human-computer interaction)

Blog Park has a "write a program for mom" moving, said the author is often in order to guide the mother of 50 to complete the operation such as copy of the exhaustion of mind, and finally custom-made a just click on the two programs, which introduced the importance of UI design. To be sure, software equals n user interfaces in terms of users. Most of them do not care about how many of the so-called advanced technologies that make developers intoxicated are simple, fast, and aesthetically appealing. The research field of human-computer interaction is churn these seemingly trivial things.


In the system design, we need to divide the automation system boundary, namely divides the system into the manual operation and the system automatic two parts, both through the user interface (Interface) completes the docking, like Figure 8-1. User interface completes the system input and output work: Collects the user to trigger the event and the related data, passes to the system internal processing and receives the processing result, the visualization processing result. In Enterprise-Class C/s applications, the function of ASPX and its background encoding file is only one--complete human-computer interaction. A beautiful web page is not the full connotation of user interface design, it should be like a good-looking, voice sweet receptionist, whisper to ask the user needs, listen to the user's rambling, patiently guide the user to complete the operation process, tolerance of user errors, accurate for the user to send the final result-" You have only 0.4 dollars left in your account and cannot complete the payment operation. In a word, to fully understand and understand the great spirit of Comrade Bai Juyi writing poetry, so that 50 of the mother happy to complete human-computer interaction.

Human motion is shadow-ASP. NET's static model

In the ASP.net architecture, the server-side asp.net page corresponds to the client's HTML page, which contains an interactive web Form that inherits from the framework's page class. The aspx file is human, the HTML-encoded temporary file is shadow, and the human motion is the shadow, both of which synthesize the user interface in the complete sense. The user carries on various operations to the shadow, the system passes the person to carry on the corresponding processing, the "request-response" feedback mechanism completes both the image process, like Figure 8-2.


HTTP is a stateless protocol, so the Web server is a bit of a knock on the head, when the response is sent will discard all request information. This will affect the usability of the application, such as asking the user to re-enter all the information in the dozens of input boxes because of data validation errors, and even the mother's fingers will be protesting. To make up for this flaw, ASP. NET uses view state (ViewState) to complete state retention. The principle is simple: the server writes the page data from each HTTP request to the generated HTML file, along with the next page submission, as shown in the following example. In the ASP era, we used <input type= "hidden" > Manual implementation, while in. NET, you will find that the HTML source code automatically generates a _viewstate tag, which is the value of the page data saved by the system.

<%@ Page language= "C #"%>
<script runat= "Server" >
protected override void OnLoad (EventArgs e) {
int val = Int. Parse (_sum. InnerText);
_sum. InnerText = (val+1). ToString ();
Base. OnLoad (e);
}
</script>
<span id= "_sum" runat= "Server" >0</span>
<input type= "Submit"/>
</form></body>


ViewState has reduced a lot of trouble, but there are also problems. By default it will be enabled, even if there is no use to collect all the page information and shuttle to and from both ends of C/s, its large body with the base 64 code often swallowed a lot of bandwidth, and there is the possibility of being threatened to cause system security problems.

Users will do various things to the interface, and want to get the system to respond, these user interface operations are. NET is referred to as an event (event, the system also generates events), and the corresponding system response is called event handling. InRandom Thoughts FourLogin page, when the user clicks on the Btnlogin button, the Btnlogin object (when it is called the event source) yells: "I was ordered, 10 years, I was finally clicked for the first time, 555~~~" but the button class itself does not define the appropriate event handlers, Then who will complete the system's actual response operation?

We have defined the member Btnlogin_click method when writing the login class. And hope to complete the processing of Btnlogin.click events, but Ms engineers in the definition of button class does not know its role, so need a medium to connect the two, then we can not help but recall theRandom Seven. NET uses the EventHandler delegate as a medium for connecting the event source to the event handler, binding both:

The procedure for the section is "Random Thoughts FourThe code fragment of Login.aspx.cs and has been modified
EventHandler for public delegates defined in the System namespace
Sender is the event source object, the EventArgs class is responsible for collecting event data
public delegate void EventHandler (Object Sender,eventargs e);
Login as trustee, complete event handling definitions and links
public class login:system.web.ui.page{
Login.oninit a protected method for the page class, perform the initialization steps required to create and set up an instance
The Init event is raised when the OnInit method is invoked
Override protected void OnInit (EventArgs e) {
New System.EventHandler generates a delegate instance
+ + completes the connection process of the event processing delegate, the same event can trigger multiple handlers, known as multicast
Base. OnInit (e) The same method used to invoke the parent class
This.btnLogin.Click + = new System.EventHandler (This.btnlogin_click);
Base. OnInit (e);
}
private void Btnlogin_click (object sender, System.EventArgs e) {...}
}
Bitter Brigade-ASP. NET's dynamic model

Each HTTP request before departure is solemn and stirring, a hero to go XI no return! Login.aspx page request to package the URL and related data on the back, hanging on the chest of their own IP address Card, from the client browser, over the telecommunications netcom man-made barriers to climb over the grassland, walk hobbled to the Web server IIS door, just want to be ecstatic for a while, when see the gate lined with long tens of thousands of requests Queues, and often starved to death when no one was in the lottery, it finally fell.

Login.aspx page requests in 矇 眬 are routed to the HttpRuntime instance, and the HttpRuntime instance will:

• Get an HTTP Application object;

• Let the HTTP Application object read the configuration file;

• Services such as session maintenance, validation, or configuration file maintenance are provided by HTTP Module instances;

· The HTTP handler interface instantiates concrete page class implementation processing.


Login is an HTML page production workshop worker who is responsible for making HTML-encoded Login.aspx pages for customers every day in accordance with stringent standards and fixed procedures. One morning, login was on the hard drive to drink coffee comfortably, body fat head HttpHandler uncle told him to start immediately.

Today is the first time to enter memory, so he first prepares the page frame and all the control parts and sets their default state, and then strictly press the OnInit method to complete the Init event, and then look for _viewstat in the page request. Read and decode the data if found, and let the control update its state to accurately reflect the corresponding element state of the client; then he took out the OnLoad method operation manual to handle the Load event, and then dealt with a series of triggered page events, including user-triggered events if the page was being echoed PreRender events handled with the OnPreRender method can change how the page is submitted, and then save the current page state to a new view state.

HTML encoding files can be generated after all of the operations are done, during which you may be able to add some HTML code by using the overwrite (override) Render method to make the final decoration for the page.

Finally login release all occupied files, graphics objects, database connections and other key resources, hurriedly ran out of memory, "It is too stuffy!" He whispered in his voice when he went out.

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.