I agree that this is less trivial with C # and then with VB. My personal preference is to simply add a function with the following signature (always works):
protected void MyButtonName_Clicked(object sender, EventArgs e) { Button btn = (Button) sender; // remember, never null, and cast always works ... etc }
Then, inside the code view of the HTML / ASP.NET part (the so-called declarative code), you simply add:
<asp:Button runat="server" OnClick="MyButtonName_Clicked" />
I find it faster in practice, and then look through several property menus that do not always work depending on focus and successful compilation, etc. You can configure EventArgs for everything there is for this event, but all events work with the basic signature above. If you donβt know the type, just place a breakpoint on this line and hover over the object e when it breaks to find out the actual type (but most of the time you will know it beforehand).
After several times, it becomes second nature. If you do not like it, wait a minute for VS2010, it has become much easier.
Note. Both VB and C # never show objects or events of elements that are placed inside naming containers (i.e. GridView, ListView). In these cases, you should do it this way.
Abel
source share