Adding an Event Handler for a Web Control's Event

As we saw in the last hour, to add the Click event handler for the Button Web control, all we need to do is double-click the button in the designer. This action will take us directly to the Code tab, where we can enter the source code for the event handler. Web controls can have more than one event, but all Web controls have what is known as the default event. When double-clicking a Web control in the designer, the event handler for its default event is created.

Since Web controls can have more than one event, you may be wondering how one would add another event handler for the Button Web control besides its Click event. To add an event handler for an event other than the default event, we must ...

Get SAMS Teach Yourself ASP.NET in 24 Hours 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.