Timothy Khouri - SingingEels.com

I subscribe to the "take it apart and rebuild it" approach to learning.

Very Insightful Moves - Thanks ASP.NET 3.5 Team!

As I was writing my latest article for Eels (Creating Your Own ListView Control), and I was reflecting how similar controls (such as the Repeater) were made, I realized that there was some poor choices made in the 2.0 framework that were very nicely corrected in the extensions brought about in .NET 3.5. I'll quit beating around the bush and I'll jump right into what I'm talking about...

The developers writing controls in 2.0 found it necessary to make a lot of "helper" classes, because there was just so much common functionality that it would be foolish to write certain functions over and over again. However, they declared those classes as INTERNAL! If they thought it was necessary to have such classes, wouldn't it be nice to let future developers use them too!?

Well, I'm glad to announce that the "DataBoundControlHelper" and the "OrderedDictionaryStateHelp" classes have been remade and declared as PUBLIC so developers like you and me can take advantage of these nice little helper classes.

Here is the code that the ListView uses when you try to set the DataKeyNames property for example... notice how they use the DataBoundControlHelper so nicely :)

public virtual void set_DataKeyNames(string[] value)
{
    if (!DataBoundControlHelper.CompareStringArrays(value, this.DataKeyNamesInternal))
    {
        if (value != null)
        {
            this._dataKeyNames = (string[])value.Clone();
        }
        else
        {
            this._dataKeyNames = null;
        }

        this.ClearDataKeys();

        this.SetRequiresDataBindingIfInitialized();
    }
}

Ahh, so nice!

Comments

Vikram said:

yes, This was a real big problem That I alos faced. If we want to create a, Asp.Net server control in the 2.0 we cannot use any of the helper class in the framework as they are all internal. Good to hear they have updated it

# September 10, 2007 12:08 AM