Quick and Dirty

2007-08-20 at 11:53 pm (Pennidren)

A coworker wrote the following code. Quick and dirty, as they said, but this is beyond quick and dirty. It’s shamefully filthy even for a hack.

private void SetAccountHistoryTabActive(string acctId) {
// Use FindControl() !!!
foreach (Control control in Page.Controls) {
if (control is HtmlForm) {
foreach (Control control2 in control.Controls) {
if (control2 is AjaxControlToolkit.TabContainer) {
foreach (Control control3 in control2.Controls) {
if (control3 is AjaxControlToolkit.TabPanel && control3.ID == “Actions”) {
foreach (Control control4 in control3.Controls[0].Controls) {
if (control4 is AjaxControlToolkit.TabContainer) {
((AjaxControlToolkit.TabContainer)control4).ActiveTabIndex = 2;
foreach (Control control5 in control4.Controls) {
if (control5.ID == “ActionsAccountHistory”) {
foreach (Control control6 in control5.Controls[0].Controls[1].Controls[0].Controls) {
if (control6.ID == “AccountHistoryControl”) {
foreach (Control control7 in control6.Controls) {
if (control7.ID == “acctId”) {
string test = control7.ID;
((TextBox)control7).Text = acctId;
}
}
}
}
}
}
}
}
}
}
}
}
}
} // end of Controls loop
}

FWIW I replaced it with a line of javascript.

UPDATE:  this person got fired

Advertisement

1 Comment

  1. Michael said,

    should’ve never let me see this site ’cause im going buck-wild on it…yes, quick and dirty could well define this colleague’s time there.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.