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.

Thursday, December 18, 2008

The Difference between "const" and "readonly" in C#

It has been baffling me for a while since I've used the two keywords for pretty much the same purposes, but after reading a little of the documentation, the difference between the two became much more clear (emphasis mine):

The readonly keyword differs from the const keyword.

A const field can only be initialized at the declaration of the field.
A readonly field can be initialized either at the declaration or in a constructor.

Therefore, readonly fields can have different values depending on the constructor used.

Also, although a const field is a compile-time constant, the readonly field can be used for run-time constants, as in this line:

public static readonly uint l1 = (uint)DateTime.Now.Ticks;

Thursday, October 30, 2008

SubWeaver: a Subversion plugin for Dreamweaver!

Awesome... a Subversion (SVN) plugin for Dreamweaver! Exactly what I was looking for!

SourceForge.net: SubWeaver


The cool thing about it is that it integrates with TortoiseSVN (at least mine did), so that part of the interface feels very familiar!

Way to go, guys!

Wednesday, October 8, 2008

WPF: Getting at information entered in Assembly Information dialog

Had a perplexing problem with Getting at information entered in Assembly Information dialog in a WPF application, and it was very quickly answered by Krisha Barghav on the MSDN forums:

WPF: Getting at information entered in Assembly Information dialog

anything you enter inside Assemblyinformation dialog sits in the AssemblyInfo.cs

You can access these values using Assembly.GetExecutingAssembly.GetCustomAttributes(true/false);

If you print the types of attributes returned, you can see something like shown below.

System.Windows.ThemeInfoAttribute
System.Diagnostics.DebuggableAttribute
System.Runtime.CompilerServices.CompilationRelaxationsAttribute
System.Runtime.InteropServices.ComVisibleAttribute
System.Reflection.AssemblyFileVersionAttribute
System.Runtime.CompilerServices.RuntimeCompatibilityAttribute
System.Reflection.AssemblyTitleAttribute
System.Reflection.AssemblyDescriptionAttribute
System.Reflection.AssemblyConfigurationAttribute
System.Reflection.AssemblyCompanyAttribute
System.Reflection.AssemblyProductAttribute
System.Reflection.AssemblyCopyrightAttribute
System.Reflection.AssemblyTrademarkAttribute


So if you want to access the Description entered in the Assembly, you can do something like this.


foreach (object o in Assembly.GetExecutingAssembly().GetCustomAttributes(true))
{
if (o is AssemblyDescriptionAttribute) Debug.WriteLine((o as AssemblyDescriptionAttribute).Description);
}

That is just an example.

Hope this helps.


Worked great for me!

Thursday, September 4, 2008

Echominder is even cooler than I thought!

A while back I wrote about Echominder from Intuit Labs, and I discovered a really cool feature that I didn't even know was in there...

Not only does echominder call you when you want it to, it also keeps a queue of your reminders on the website, and you can re-remind yourself by telling it to send you a particular message at a specific time (again).

Previously I was under the impression that the messaging was just a one-time event. Turns out I was wrong (and can't read documentation)! Awesome!

Kaxaml - Great Lightweight XAML Editor

So after checking out some of the WPF Bootcamp sessions at MIX08, I decided to install and try out Kaxaml...

Kaxaml

...and it's great! It's really nice to be able to try out the default snippets that are in the tool, and then to be able to grab XAML code blocks off the web and try them out on-the-fly without having to create a Visual Studio 2008 project - which is just too time consuming to try stuff out.

A very nice, and in my opinion, agile development tool!