Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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)?

like image 926
dotnetN00b Avatar asked May 25 '11 20:05

dotnetN00b


2 Answers

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

Menu1.MenuItemClick += Menu1_MenuItemClick;
like image 187
Bala R Avatar answered Sep 27 '22 21:09

Bala R


You have to assign the events yourself using the += syntax.

like image 42
Guvante Avatar answered Sep 27 '22 21:09

Guvante