Overview
This blog and the previous Blog have some repeated parts. If you want to learn more about the relevant content, you can view it in the relevant connection blog. This blog introduces what is Asp.net, Asp.net's interaction process on the browser and server, and the differences between Asp.net's server controls and client controls. The explanation may not be clear. If you have any questions about the content, please let us know in the comments. Let's discuss it together!
World Wide Web and HTML
Here we will not explain why the World Wide Web and the benefits it brings to us. We will only talk about its implementation. The World Wide Web is a resource sharing network, not a physical network, it is a network established before the physical network, a virtual network, and a network that transmits data through HTTP. OK. Here we talk about data, what kind of code should be used for data transmission? Previously, it was represented by an ascii code. It is not clear (it may be a unicode Code). If you want to know it, you can tell me in the comments. In fact, we do not need to know its specific encoding, because the browser now uses the encoding and decoding mechanism. Otherwise, we will not be able to see the real data. We can see the specific data, next, let's take a look at this. How is the specific data displayed in the browser? Whether it is horizontal or vertical, whether it is blue or red, etc. The computer does not know, because the encoding of the specific data transmitted by the computer only represents the specific value, and its shape is not involved at all, so how can we solve this problem? We can specify some special characters in advance to give them some meaning, so that we can write specific data and use these special characters in the browser when setting them, when data is displayed, the program that explains these special characters is displayed.
The special characters above are called HTML tags (including corresponding attributes). HTML documents are the files where these tags and specific data are mixed. Of course, they have developed to the present, this combination of data values and data shapes is no longer applicable, and the data shapes have been replaced by CSS. As for the CSS issue, it is not the focus of this blog. For details about how to learn HTML, refer to this blog: Summary of basic HTML knowledge. For more information about the World Wide Web, refer to this blog: www
HTTP URL
Client script
After learning about HTML, let's talk about the client script. Client scripts can reduce the burden on the server (verify the correctness of input data on the client (browser) through client scripts ), client scripts can make the interface more friendly (dynamic page effects can occur without communication with the server), and so on, client scripts bring us a lot of benefits, however, what problems does it generate? You need to know that the emergence of any new thing is not for no reason, "not icing on the cake, or sending carbon in the snow", so what is the client script generated? This is not clear to me. My speculation is to reduce the burden on the server, that is, the client script is available only after the server script is available. This statement may not be correct. You may want to know the answer in the comments. In fact, we want to talk about the above. We should not take things for granted, and we should learn to trace the source.
What is a client script? A client script is a collection of special characters. The combination of these special characters has a certain significance and format. Of course, the browser must also have a program to explain these special characters. Otherwise, those special characters won't have special meaning, which is similar to our previous explanation of HTML. To enable our HTML documents to have these functions, we will add a set of special characters to the HTML documents written on the server according to the requirements of the client script, in this way, when the browser obtains the HTML document and triggers this function, the corresponding interpreter of the browser will explain the collection of these special characters. There are many client scripts, such as javascripte and vbscripted.
The following figure shows a blog post (a document on the World Wide Web). After reading the text above, let's see if it feels classic.
Server scripts
The client (browser) script is mentioned above. Let's take a look at this server script in the form of a question.
I have nothing to say. First, ask why the server script exists? It is to solve a problem or to icing on the cake. Let's talk about it. We have introduced some understanding about hmtl, but you can refer to this blog for details: in the summary of basic HTML knowledge, if you have learned HTML and used it, you must have the feeling that the communication between the client (browser) and the web server is too bad, you may say, yes, it is similar to no interaction. In fact, our server-side scripting technology is generated because of this problem.
The server script is an application running on the server. Now you may have questions. What are you doing to run this? Okay. Let's talk about the interaction process between browsers and servers in the static Web page era: the browser accesses the corresponding static Web page through a URL, and the Web server processes the request, when I access this static webpage, I send the corresponding static webpage to the requester, and the interaction is complete. Now let's take a look at the interaction between the browser and the server after the server script is used: the browser accesses the Corresponding Dynamic Webpage Through the URL, and the Web server processes the request after receiving it, first, access to the dynamic web page. Second, the data is sent to another control program. The control program receives the data and then processes it. First, access the dynamic web page, run the webpage and the code in it immediately, and generate a static html file based on the browser data, and then send it to the visitor (browser ). Of course, the server must provide a runtime environment for Running code on dynamic web pages. Here, the code in the dynamic web page makes the server more powerful. For the interaction between the browser and the client, you 'd better draw a picture by yourself. There are many scripts on the server, such as PHP and Asp.net. In this blog, we mainly talk about Asp.net.
The figure described by the browser and server in the server script is roughly as follows:
The figure below, including the figure I have drawn above, is a supplement after posting this blog, especially the figure below (copied by Wang zhipeng's blog ), this figure, coupled with the first figure of this blog, perfectly explains the detailed process of working on the client and server. I hope you can understand these two figures.
Asp.net
We have mentioned some introduction to Asp.net above. Now let's start with a real introduction to Asp.net. The reason for the emergence of Asp.net can only be said to be icing on the cake. It is not a result of the snow. If the specific situation is not good, I will not talk about it much. What is Asp.net? What is it? In fact, Asp.net is a solution that completes the entire process from the design to the specific details. Of course, we will have different focuses on it from different perspectives, for example, from the programmer's point of view, we think that it is a set of special characters and a scripting language. From the perspective of Asp.net implementation, from the perspective of providing such services for programmers, he is more about a technology and wants to elaborate on some behind-the-scenes things to achieve this.
From the programmer's point of view, Asp.net, I prefer to say that he is in. development of B/S interface standards on the. NET platform, because. when developing the B/S program interface on the net platform, the same symbolic set (including controls) is used, that is, the same thing is used: Asp.net. Asp.net in. the entire architecture of net is in the application development language (C #, VB.net, etc.) and. among the Net Framework class libraries, all the "Asp.net" things used by development languages in development B/S are Asp.net. In fact, Windows
Form and Asp.net are in the same position, but because it is not like Asp.net, it has to worry about HTML, so there is no repetitive thing, that is, for Windows form, you only need to properly design the interface, instead of writing some Page code design. From here we can know that C # And VB.net are based on. the application programming language of the. NET platform, some of the controls used in writing form applications are the same. For a deeper understanding of. net,. NET Framework, and other knowledge, you can take a look at this blog:. Net learning summary.
OK. I believe you have a clear understanding of Asp.net. Now let's talk about its interaction process between the browser and the server, in fact, the process of interaction between dynamic Web browsers and servers has been mentioned above. The reason for this is to give everyone a more intuitive understanding. Interaction between the browser and the Web server: the browser sends the corresponding Asp.net page request. After the server receives the request, it immediately gives the corresponding control program, after receiving the control program, it searches for the corresponding file, runs it, generates the corresponding static HTML document, forwards it to the control program, and then sends it to the corresponding requestor. This process is a rough process. I am not quite clear about the events corresponding to a specific stage. As for the current stage, I understand this first: After the control program receives a request from the client, A "template" static html (document not initialized in the Asp.net document) will be obtained as required. Then, check whether the request contains the data of the objects in the initialization webpage. If yes, initialize it, otherwise, call the load event of Asp.net to initialize the static HTML to be generated (you can select the condition through ispostback), and then execute the corresponding control to trigger the event. The descriptions here may not be very clear. We will describe the specific controls below.
Asp.net Control
Controls involved in the Asp.net webpage can be divided into two types: client controls and server controls.
The client control is a control made of HTML tags. The essence of the control is HTML tags. When we design the Asp.net interface, we can use the corresponding HTML control layout in the toolbox, you can also write HTML tags in the interface code for layout. The reason why the HTML Tag control exists in Asp.net technology is mainly compatible with the previous HTML, which will be explained in detail later.
Server-side controls can be divided into two types: HTML server-side controls and Asp.net server-side controls. The HTML Server Control is added to the HTML Tag: runat = "server", id = "unique identifier "; asp.net server-side controls are the real things of Asp.net. Here we want to say that any HTML Tag control can be implemented by Asp.net server controls, and Asp.net server controls can be divided: controls set on the web interface; verification controls. Of course, from another perspective, we can also divide it into custom controls (third-party controls) and system controls (first and second-party controls ). You probably know.
I have mentioned so many things about client controls and server controls. Maybe you should be confused now. What is the difference between client controls and server controls? Maybe you will think that the client control is the control that runs on the client, and the server control is the control that runs on the server. Here you can think about it and verify that the control is a server control? First, let's talk about the features of the verification control. There are many verification controls, some are executed on the client, some are executed on the server, and so can be said that the verification control is a server control. For this sentence: the client control is the control that runs the client, and the server control is the control that runs on the server. If we only understand the difference at this level, we can only say that we have not really understood the difference between them. Why? Because the sentence just now is actually an abstract sentence. What does it mean? That is, based on this sentence, we can have a variety of different implementations to understand. It is a terrible thing. How can we solve this or this type of abstract sentence problem? One sentence: Practice witness. Now, let's talk about the differences between them. A server-side control is a control that can be accessed by background code and can perform any operations on it. Client controls or HTML Tag controls cannot be directly operated by background script code.
Here we need to know that the browser interacts with the server through a form (that is, the "<form>" tag). However, the server access control is to see if it is a server control. As we have mentioned above, the server control program first assigns the data information in the form to the static HTML that is being formed, then, trigger the load event of Asp.net. Then, the control program looks at the control event triggered based on the data information in the form, then returns the entire static HTML to the browser, and the browser displays it again.
If you are careful about this situation, the Asp.net server controls are all in the <form> form. If they are not in the form, errors will occur, because the server control program requires the status information of those controls and is used to generate new static HTML documents, this process is prior to the load event on the Asp.net webpage, of course, if we do not care about the changes to the current interface, we can set the corresponding attributes to not pass over. Viewstate can be disabled for a single control, the entire page, or the entire application. For details, add enableviewstate = "false" to the attributes of each control label "; add enableviewstate = "false" to the page settings of each page (usually the first line of each page ". Note that this setting is applicable to the textbox, checkbox, and checkbox controls on the server.
List, radiobuttonlist is invalid.
As mentioned above, we mainly want to figure out a few things: there is a data initialization before the load event, and the types of initialization data include specific data and messages, the initialization function is to maintain the status of the server-side controls on the browser. The interaction between the browser and the server must be performed through forms. The background code can access the server-side controls and generate static HTML documents, the browser needs to be re-displayed. The lecture is a bit messy. I hope readers will be able to trigger more questions after reading it.
Summary
I originally wanted to write the built-in objects of Asp.net and the corresponding reflection summary on this blog. However, when I read so many words, I will not write them. I will not post a blog on the specific content of the Asp.net control. I will post a Summary of the Asp.net built-in objects and reflections.