Note that there are some explanatory texts on larger screens.

plurals
  1. POMoving asp.net team from VB.Net to C#, seems are we are missing something with wiring up events?
    primarykey
    data
    text
    <p>An asp.net (mostly webforms) team I work on has recently decided to make the move from vb.net to c#. The people who used to be on the team who couldn't read/write C# code well had since moved on, and each time we hired a new person it became more of a problem for us to be a vb.net shop.</p> <p>I'll save the standard vb/c# language war stuff and just stick with the one thing that I ran into today. </p> <p>With vb.net, when we want to handle some event from some object, we just pick the object out of the list in the upper left, pick the event out of the list on the upper right, and it creates the fully wired up event handler. It's also very clear that the method is an event handler due to the "Handles ... " at the end.</p> <p>In the C# world, it <em>seems</em> we are left with a few poor options. </p> <p>1) Manually wireup the event by typing the name of the event and event handler in the aspx markup. Like actually writing "OnLoad=SomeFunction" in the aspx. (EDIT: I didn't realize that his only applied to the form and not to any contained controls, so I guess this isn't really an option)</p> <p>2) Using auto wireup events, and naming methods and signatures correctly so that they match up.</p> <p>I'm hoping I'm missing some other much better option.</p> <p>With these 2 options that I've seen so far:</p> <p>1) we have to know the event names and event arguments. We can't just look down the list and be like "Oh good this has OnItemClick", I have to go research that in some control documentation. Likewise I'd have to go research the event args to find out that ItemClick needs a RadPanelBarEventArgs as the 2nd parameter. Wasted time.</p> <p>2) I get no compile check on anything I'm doing with regard to connecting events. If I name the method signature wrong, or if I type it in wrong in the aspx page, everything will compile just fine until runtime when the mismatch will blow things up. (EDIT: what I mean is if I type onClick="ABC" and the event handler is really named "ABCD" this will not be caught at compile time. With VB, issues with renaming/mistyping event handler names are caught at compile time, because of the "Handles". Same goes for if I have onClick="ABC" and this controls onClick really needs a SpecialEventArgs but I accidentally use SomeRegularEventArgs)</p> <p>I'm hoping we missed something and there is a better way to do this. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload