Search code examples
c#.netasp.netvb.nethandles

Does C# have a Handles keyword?


Protected Sub Menu1_MenuItemClick(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.MenuEventArgs) Handles Menu1.MenuItemClick


End Sub

In VB.net, we have the Handles keyword, I'm wondering if C# has anything comparable. Or do you have to manually wire all the methods to each control's event (in ASP.NET especially)?


Solution

  • Nope. You will have to wire up the event like this

    Menu1.MenuItemClick += Menu1_MenuItemClick;