tags:

views:

46

answers:

1

Is there any way to cause a compilation error if an ASP.NET control declares an event handler that is not implemented? For example, I declared a TextBox

<asp:TextBox ID="uxFeeQty" runat="server" MaxLength="2" Columns="2" 
    AutoPostBack="true" 
    OnTextChanged="ReCalculateFees" 
    style="text-align:right;" />

but neglected to implement the ReCalculateFees event handler. This error wasn't apparent until I browsed to the page and it threw a run time exception. Is there any way to catch this error at compile time? I could subscribe my handlers in code rather than declaratively but that would require a significant clean-up effort.

+2  A: 

Not to suggest spending more money, but ReSharper's Solution-wide analysis will flag all of those things for you. It has saved me often enough to justify the price of the tool.

ProKiner
Actually, I already have it and had read about the new solution wide analysis feature in 4.5 but I hadn't been able to find it to turn it on! Your answer prompted me to try again so I did some digging and discovered it in Resharper > Windows > Errors in Solution. Thanks.
Jamie Ide
No worries... beware it slows things down on a really large solution, so I just turn it on periodically for a sanity check.
ProKiner