Due to the code-behind logic, handling events in ASP.NET applications looks similar to what you saw about WPF. This means that you have a user control implemented on the XHTML side and an event handler in the Visual Basic side.
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:
You can handle the Button.Click
as usual, for example with the following code that writes a message to the Label
:
Notice that you can also specify the event handler in the XHTML code, avoiding the Handles clause on the VB side, exactly as in WPF. The Click
event handler is specified with the OnClick
attribute:
<asp:Button ID="Button1" runat="server" Text="Button"
OnClick="Button1_Click" />
And then you write the event handler without Handles
:
3.141.104.67