When somebody changes my code...

Well, initially I might get upset, but only if they break something. But here I am not talking a team member changing your code... No... that's OK

This blog entry is about that 'non-deterministic' behavior that sometimes happens to 'us' while developing software and all of the sudden something does not work as it 'should' be. Who does not hate that kind of bugs right? This example is a real case scenario using Telerik components in a web application.

Consider the following piece of ASPX code, I have placed a button and a label, the button 's click event in code-behind event will change the value of the label.

Pretty simple right? Just a button with a javascript confirmation dialog before performing the page's post back. Now lets 'ajaxify' this...

Using the new ajaxified code now have pretty much same effect, except we are not performing a full page post back, but only updating elements inside the UpdatePanel control. But what if I have a page already with lot of telerik stuff? I wont be using the classic asp.net controls, I will use the Telerik stuff.. now lets do it with Telerik !

What a surprise, It will *not* work.... however... it should... why is it failing then? In order to figure out that, let's check the HTML code rendered by the ASP.NET page where we used the Telerik components.

Wow.... my javascript has changed... and it has the "do postback" call after it! But I didn't do that right? That's not a new behavior, postback codes are changed a lot in .NET, but for my experience, whenever ASP.NET or anything change that code, it always works...

Fortunately is easy to fix, just a small change; instead of return confirm('are you sure?'); I just changed that line of code to: if (confirm('are you sure?')) That way it will generate a complete condition that will do the postback after the confirmation.

Don't get me wrong, I like Telerik a lot, and I used their components a lot... but... don't touch my code.



Comments

Popular posts from this blog

Get-ChildItem vs Dir in PowerShell

The case for a 4 week sprint

NODE.js fs.readFile and the BOM marker