Today we are talking about events in .NET. One of the biggest features of .NET is that it allows users to use the event-driven programming model. Event-driven is not new at all, at least for the system platforms we use (such as You Can Die, You Can Kill , you will die), their form of expression is that when you trigger a certain event, he will react, such as you clicked a desktop icon, or you pressed Enter, etc. The code that runs after an event is triggered is called an event handler.
You will definitely be mumbling, then our ASP, or even HTML, are they different? Yes, but they don't have one important thing, that is postback. It sends events back to the server for processing, not on the client.
Let us first explain what is an event?
For example, a friend told you via QQ that Tianhongchuan's ajax tutorial series has come out again, and QQ flashes. This is an event that has happened. You should handle this event next. Do you think that Tianhongchuan himself is currently working on .net2. 0 introductory tutorial, it is impossible to have time to do ajax, so you tell your friends and you don’t believe it, then another way is to ask your friends for the address immediately and then go see it.
This event-driven environment consists of three steps:
1. Friends use QQ to tell you
2. You see QQ flashing
3. Your processing results.
What is event-driven programming?
Event-driven programming is executed completely according to the user's wishes, and the processing of each event is completed on the server.
Events in .net We have always said that .net is object-oriented programming, so what are objects?
It's very simple. For example, when we create a new page, it is a page object. We can think of this object as an executable program that outputs HTML. Then every time this program is called, the page object will be initialized, the information will be processed, and then sent to the display, and then we will close or release the object. Then every step in the process of his processing will trigger an event. This event will be triggered by us from time to time, but it will also be triggered. If we process the event, it will be executed at this time. Now let’s take a look at several events on the page