ASP Versus ASP.NET Events

ASP was primarily a linear programming model. It had six events, of which only four were commonly used. These were:

  • Application_OnStart, which was fired when the application started

  • Application_OnEnd, which was fired when the application terminated

  • Session_OnStart, which was fired at the beginning of each session

  • Session_OnEnd, which was raised when the session ended

ASP.NET, on the other hand, is primarily an event-driven programming model. The application has events, each session has events, and the page and most of the server controls can also raise events. All ASP.NET events are handled on the server. Some events cause an immediate posting to the server, while other events are simply stored until the next time the page is posted back to the server.

Because they are handled on the server, ASP.NET events are somewhat different from events in traditional client applications, in which both the event itself and the event handler occur on the client. In ASP.NET applications, however, an event is typically raised on the client but handled on the server.

Consider a classic ASP web page with a button control on it. A Click event is raised when the button is clicked. This event is handled by the client (i.e., the browser), which responds by posting the form to the server. No event handling occurs server-side.

Now consider an ASP.NET web page with a similar button control. The difference between an ASP.NET button control and a classic HTML button control ...

Get Programming ASP .NET now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.