logo
  • Jobs
  • About Me
  • Contact
  • Home

Archive for November, 2005

« Previous Entries

Firefox 1.5

Looks like the Mozilla group has released Firefox 1.5.

Some of the new features:

  • Automatic updates
  • Improved popup blocking
  • Clear private data tool

Congrats to the Mozilla team on reaching this milestone.

No Comments

John Vlissides

From Grady Booch’s blog, I just got the sad news that John Vlissides, one of the Gang of Four, passed away early Thursday morning after being diagnosed with brain cancer in early 2004.

John’s contributions to the software and patterns community are immeasurable and he will be missed.

No Comments

Happy Thanksgiving

I just want to take a minute and wish everyone a very safe and happy Thanksgiving!

Enjoy the time with your families.

No Comments

Ordering your javascript while using RegisterClientScriptBlock

Earlier today I stumbled across an interesting issue while using Page.RegisterClientScriptBlock to register some javascript to be output to the browser. The order of output was very important, because one of the scripts depended on a previous script being registered.

Everything worked great, except for one page. It seems like it’s always that way, doesnt it? No matter what I did, this javascript would be output in a different order than I registered them.

After digging into this for quite some time, I finally decided to break open Reflector. By the way, have I ever told you that this is the coolest tool ever? After investigating the Page class (specifically RegisterClientScriptBlock), I quickly saw what the problem was.

RegisterClientScriptBlock calls a private method called RegisterScriptBlock, which takes an IDictionary as a parameter. If the IDictionary is null, RegisterScriptBlock initializes it to a new HybridDictionary. HybridDictionary starts as a ListDictionary, which is an IDictionary implemented using a singly linked list. However, once HybridDictionary gets to be over 9 elements, it switches over to a Hashtable.

Where this is going is that once you switch to a Hashtable, you lose all the ordering benefits of ListDictionary. Clearly this is whats causing my problem. :)

It would be rude to not present a resolution to my problem so here goes:

My application has a common base class, so it seemed logical to override some methods to achieve the desired functionality. The easiest solution would have been to override RegisterScriptBlock in a Page derived class to use a ListDictionary, but alas, RegisterScriptBlock is private. No luck there…

This is what I came up with…

public class MyBasePage : System.Web.UI.Page
{
    private IDictionary scriptBlocks = new ListDictionary();
 
    public override void RegisterClientScriptBlock(string key, string script)
    {
        if (!scriptBlocks.Contains(key))
        {
            scriptBlocks.Add(key, script);
        }
    }
 
    public override void Render(System.Web.UI.HtmlTextWriter writer)
    {
        StringBuilder sb = new StringBuilder();
 
        foreach (string scriptBlock in scriptBlocks.Values)
        {
            sb.Append(scriptBlock);
            sb.Append("\r\n");
        }
 
        base.RegisterClientScriptBlock("completeScript", sb.ToString());
        base.Render(writer);
    }
}

It should be fairly apparent what this code does. I really like this approach, because none of the calling code has to change to fix this issue. All 3rd party components will work with this implementation, since all calls are still to RegisterClientScriptBlock.

One thing about this that still needs to be addressed though is the IsClientScriptBlockRegistered method. Microsoft, for some inexplicable reason, has decided to make RegisterClientScriptBlock virtual allowing you to override its implementation (like we have done by providing a new storage mechanism). However, it did not make IsClientScriptBlockRegistered virtual. So, while we have a new data store for our script blocks, a call to IsClientScriptBlockRegistered will return false.

To fix this, you can do this…

public new bool IsClientScriptBlockRegistered(string key)
{
    return scriptBlocks.Contains(key);
}

Im not sure I like this, because this means that the new method is available only when the object is cast to the type the method is specified in.

5 Comments

El Baile De Yoda

Yoda’s cuttin’ a rug (in Spanish)…

Hysterical…

No Comments

VistaDB 2.1

VistaDB is giving away free licenses to bloggers that spread the word about their embedded database. Free licenses, goooood! Here we go:

VistaDB 2.1 database for .NET has been released
This 2.1 update includes over 60 improvements, including new support for .NET 2.0 and Visual Studio 2005. VistaDB is a small-footprint, embedded SQL database alternative to Jet/Access, MSDE and SQL Server Express 2005 that enables developers to build .NET 1.1 and .NET 2.0 applications. Features SQL-92 support, small 500KB embedded footprint, free 2-User VistaDB Server for remote TCP/IP data access, royalty free distribution for both embedded and server, Copy ‘n Go! deployment, managed ADO.NET Provider, data management and data migration tools. Free trial is available for download.

- Learn more about VistaDB
- Repost this to your blog and receive a FREE copy of VistaDB 2.1!

No Comments

CruiseControl.NET

Looks like the Thoughtworks group has released the final 1.0 version of CruiseControl.NET (release notes). If you havent yet discovered the joys of continuous integration, you really need to read about the benefits of developing this way.

Having worked under continuous integration for the past 2 years, there is no way I would go back to anything else.

No Comments

Passing Items around in ASP.NET

Wow, something as simple as keeping an item around between requests has proven to be an incredibly tedious task in ASP.NET.

The initial implementation had this identifier stored in Session state. This however, proved to not work as well as we needed it to, because we needed the item to be available even after the session expired.

Next thought was that we could have a base class that registers a hidden field with this identifier and when the page loads, it reads the identifier and reconstitutes the object needed from this id. This worked great until…

Plain anchor (a href) tags. Plain anchor tags obviously dont submit a form to the server, and therefore, my identifier was no longer available.

Seems to be that the only way to keep this identifier persistent across requests *and* sessions is to add the item to *every* querystring and then also register the hidden field (for pages that postback).

What a colossal pain in the ass! The thought of thinking that I could break my entire app if I forget to generate a URL without this identifer in it makes me cringe.

Has anyone done something similar to this before and how have you solved it?

9 Comments

An interesting thought

“The books you read today will fuel your earning power tomorrow.”

– Tim Sanders, Love is the Killer App

I’ve made a conscious decision to keep the television off (thanks to some good tips from 43Folders) and taking that time to improve myself.

What books am I reading now?

  • How to Win Friends and Influence People
  • The 7 Habits of Highly Effective People
  • The Millionaire Next Door
  • The Quick and Easy Way to Effective Speaking
  • Ship it! A Practical Guide to Successful Software Projects
2 Comments

No one individual is greater than the team

No one individual is greater than the team. This idea was brought home by some things that happened in the NFL this weekend.

Terrell Owens is probably one of the best receivers in the league as far as raw talent goes. While with the San Francisco 49ers, he was never really content to let his skills do the talking. He was no stranger to controversy, on the field and off. Some of his more famous moments include gems like running out from the end zone to pose on the Dallas Cowboy’s star on the 50 yard line. Also, signing a ball that he caught for a touchdown, with a Sharpie that he had stored in his sock, and then giving that ball to his agent.

Last year, after causing a considerable stink, NFL wide receiver Terrell Owens signed with the Philadelphia Eagles, and along with QB Donovan McNabb took the Eagles all the way to the Super Bowl, where they ended up losing.

And here is where the wheels came of for Terrell… A rough recap of the things that happened since that loss:

  1. Owens makes comments to a reporter about how he “wasn’t the guy who got tired in the Super Bowl”. By throwing his QB under a bus, he ignites a feud with McNabb in which the two don’t speak for several months
  2. Owens fires his agent and hires mega-agent Drew Rosenhaus and wants to redo his deal, claiming that he outperformed his 7 year, $49M contract. This saga included such gems as, “You know, I’m just trying to feed my family.” Right, because I’m sure your family is eating Ramen noodles on your $49M salary.
  3. He’s upset with the organization that there was no in-stadium acknowledgement of his 100th TD reception. “That right there just shows you the type of class and integrity that they claim not to be. They claim to be first class and the best organization. It’s an embarrassment. It just shows a lack of class they have.”
  4. Engaged in a fist fight in the locker room with another teammate
  5. Insists that the Eagles would be undefeated with Brett Favre at quarterback. Once again he throws his quarterback under the bus to feed his own inflated ego.

Head coach Andy Reid and the rest of the organization seem to have had enough. On Saturday, the Eagles suspended Owens indefinitely for conduct detrimental to the team. They have drawn a line in the sand and sent a very clear message by benching arguably the best receiver in the league because he can not get along with the rest of the team.

It does not matter how good you are, if you cannot exist in harmony with the other members on your team, that team will move on without you.

No Comments
« Previous Entries
flag
Favorite Charity
wounded warrior project
Search
Social
  • mattberther on twitter
  • mattberther on linkedin
Syndication
Archives
  • January 2010
  • September 2009
  • July 2009
  • June 2009
  • February 2009
  • January 2009
  • December 2008
  • November 2008
  • September 2008
  • August 2008
  • June 2008
  • May 2008
  • April 2008
  • March 2008
  • February 2008
  • January 2008
  • December 2007
  • November 2007
  • October 2007
  • September 2007
  • August 2007
  • July 2007
  • June 2007
  • May 2007
  • April 2007
  • March 2007
  • February 2007
  • January 2007
  • December 2006
  • November 2006
  • October 2006
  • September 2006
  • August 2006
  • July 2006
  • June 2006
  • May 2006
  • April 2006
  • March 2006
  • February 2006
  • January 2006
  • December 2005
  • November 2005
  • October 2005
  • September 2005
  • August 2005
  • July 2005
  • June 2005
  • May 2005
  • April 2005
  • March 2005
  • February 2005
  • January 2005
  • December 2004
  • November 2004
  • October 2004
  • September 2004
  • August 2004
  • July 2004
  • June 2004
  • May 2004
  • April 2004
  • March 2004
  • February 2004
  • January 2004
  • December 2003
  • November 2003
  • October 2003
  • September 2003
  • August 2003
  • July 2003
  • June 2003
  • May 2003
  • April 2003
  • March 2003
mattberther.com © 2003 - 2010