CHAPTER 5 ?– SERVER CONTROL EVEN TS 185
Figure 5-2. Server-side control events in ASP.NET
When a user clicks a Button in a web form and the browser performs an HTTP POST back to
the web server, ASP.NET builds the page control tree on the server to dynamically handle the
postback request. As discussed in Chapter 3, ASP.NET gives each control in the control tree
that has ViewState enabled a chance to examine posted data through its LoadPostData method.
In this method, the control can examine the user input on the server via the posted data and
compare it to what was previously stored in ViewState. If the data has indeed changed, and if
the control has an event that can be fired in response to the data change, the control should
return true to ASP.NET in LoadPostData. Later on in the page life cycle, ASP.NET will call the
RaisePostDataChangedEvent member for each server control that returned true in LoadPostData so
that the control can, in turn, raise the appropriate event and execute any business logic implemented
via an event handler written by the developer. This is the ASP.NET page life cycle that
repeats during each postback for state (data) changes and event firing. Before we dive into writing
events for ASP.
Pages:
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281