in
ASP.NET
Middle, whole
Web
The page is placed in a big form. Such as:
HEAD>
The specific content of the web page ...
Form>
Body>
Html>
Many HTML controls such as buttons, drop-down menus, text boxes, etc. may be placed in this form. ASP.NET provides some server-side web controls. When executed on the server, through a certain condition, the web form converts these server web controls to a normal HTML control. For example, a button:
asp: button >
After the conversion is changed:
In fact, ASP.NET uses or has some existing technologies. It is only, it has been encapsulated these existing technologies so that you will increase yourself to an application level.
In ASP.NET, a web form is seen as an object. Its data member is the variables that Web controls and your own definition, and its function members are those functions used to respond to client operations, of course, you have defined functions. I roughly explained what incident occurred when the user requested a web page:
Note: A web page is implemented by three files: HTML, background program code, resource file.
Suppose: There is a tab control and a button control in the web page. When the text is initially: "Initial"
First, the user performs the page to execute the page_init process of the web page for the first time, and the components are typically initialized. Then execute the Page_Load process, here, we can do some initialization work. For example: Set the text of the label control: "Initial". Then, since the user is the first request page, there is no other event. Program Control is converted to interpret server code in the HTML code page. In HTML, there is a this is our label control. Because we have valued the text of the label during the page_load, now the program will now convert to Initial span>. And button conversion is similar to what I have already said. After these conversions, the code in the HTML page becomes a standard code. These codes are then obtained by the user browser. After parsing, the user can see a "initial" and a button. Now, the user clicks on the button. So, the form is submitted. (The details of the submit, I will say below)
By submitting a form, the server knows that this is the user clicking on the button control. And this is the user's second time requesting the page. Thus, the program executes the PAGE_INIT process, and the Page_Load process. At this time, because the user clicks the button control, the program starts to perform another function, which is used to deal with the user's click control. Here, we set the text of the label control to: "click". The program is then transferred to the HTML page. Like the first request above. So the user can see a "click" and a button through the browser through the browser.
In actual use, the program code in the background is compiled into binary code.
Let's talk about the details of the submission form.
The user's operation usually produces some events, but it is some client events. That is to say that these are not related to the server. To get in touch with the server, you must pass the request. Microsoft chose to submit it.
In .NET, the content of the web form is placed in a big form. For the button, Microsoft converts them to is the submission button in HTML. Because each button ID, Name is different, so the server can tell which button is pressed, and then generates the corresponding server event. As the user in the above example click the button event. And perform the corresponding operation. For other controls such as the drop-down menu, if you want to process by the server after the user changes the selection of the menu, you also need to convert the client event to a server-side event. NET adds a few
Function __dopostback (evenettarget, eventargument) {
Var theform = Document.form1; // Form1 is the name of the form
Theform .__ EventTarget.Value = EventTarget; // __EventTarget is Hidden
Theform .__ Eventargument.Value = Eventargument; //_Eventargument is Hidden
Theform.submit (); // Submit a form
}
In fact, you can see that .NET is the name of the control of the client by hiding the control, such as the number of controls that generate events. Then, submit the form. In this way, the server side can determine the name of the control generated by the hidden control, and generate server events, which will process the event.
can be seen,
Relatively
ASP 3.0
Different places
.NET
Package a lot of features and provide a lot of new server components. Make the program more simple. in
ASP3.0
In the middle, the program code is embedded.
HTML
Code in the code. The advantage is that the flexibility is higher, but it is not easy to add a lot of features in the same page (because face a large number of embedded
In the code
ASP
Code, the incorrect generation is difficult to avoid). in
In these, these have been changed.
Put the program code
The code is divided. And providing a large number of convenient server controls. This makes it developed
Programs become very simple. But in the actual use process, I found that if it is too dependent on these controls, the flexibility of programming will become smaller. And there is a lot of discovery during use.
Bug
.