Handling Events

Due to the code-behind logic, handling events in ASP.NET applications looks similar to what you saw with WPF. This means that a user control is implemented on the XHTML side and an event handler in the Visual Basic side.

Handling Events Tip

If you need to catch events from objects that are not user controls, such as business objects or collections, you just write the event handler in Visual Basic code the usual way.

For example, consider the following XHTML code that provides a Button and a Label:

<form id="form1" runat="server"><div>    <asp:Button ID="Button1" runat="server" Text="Button"/>    <asp:Label ID="Label1" runat="server"></asp:Label></div></form>

You can handle the Button.Click as ...

Get Visual Basic 2015 Unleashed 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.