Friday, January 30, 2009

ASP.NET Bug: Button.OnClientClick

I really don't understand this one.

According to the ASP.NET MSDN online documentation for Button.OnClientClick Property (System.Web.UI.WebControls), you use Button.OnClientClick to assign a client-side script (javascript) when the button is clicked (for example if you want to have the button perform some action(s) before submitting, or to short-circuit the click entirely).

However, I couldn't understand why the client-side onclick handler was not getting rendered, no matter what I tried!!!

Then I scrolled down to the bottom and noticed the comment by user contributor "Perley":

"MS has made it so that if you disable the button on the server then the onclick attribute is not even rendered to the client"


Mystery solved.

I had indeed set the button to be disabled in the markup, and it was flat-out not rendering the onclick handler in the HTML.

I fixed the problem by wiring up the onclick event for the button manually using a pageLoad function, but still it was a hassle.

I really think the people who designed, approved, and coded that "feature" should get their head checked, because, seriously... if a button is disabled initially, don't you think it's possible that the button - a user interaction device - might become enabled at some point, and not through server-side intervention???

Monday, January 19, 2009

.NET Rocks! Epsiode 406: Catching up with Scott Bellware

This episode of .NET Rocks! features an interview with Scott Bellware, who describes some new unit testing and coding practices that sounded very innovative, introducing the concepts of usability into your code:

.NET Rocks! - Epsiode 406: Catching up with Scott Bellware

...I just thought some might find it interesting. I did.