CodeSOD: Parents In Control

This post was originally published on this site

The Daily WTF

I’ve said many unkind things about ASP.Net WebForms in the past. While it leaves a lot to be desired as a web development environment, its event driven approach does map to a lot of folks understanding of software. Click a button, execute code in response. Change a radio button, execute code in response. A simple, easy to understand architecture.

Well, sometimes simple and easy to understand.

A number of years ago, Kyle was tasked with updating his employer’s “benefits election” site for the new year, and found this:

Protected Sub rdoSmokeYes_CheckedChanged(sender As Object, e As System.EventArgs) Dim rdoEmployeeYes As RadioButton rdoEmployeeYes = CType(CType(sender, RadioButton).Parent, Panel).FindControl(“rdoSmokeYes”) […snip…] End Sub

This is an event handler. If the user altered the rdoSmokeYes radio button, this event handler will fire. The ASP.Net event handler takes two

To read the full article click on the 'post' link at the top.