General Ramblings comments edit

We put the [fake] Christmas tree up yesterday and decorated the house a bit.  It sort of got that nice, cozy holiday feel to it.

Both of the cats started promptly chewing on the limbs they could reach, in many cases actually swallowing the nylon needles they were able to extract.  While my cat seems more interested in the act of chewing than the actual extraction of needles, Jenn’s little wild man seems hell bent on a combination of destruction and consumption.

Woke up this morning and found about eight cat puke spots in various places throughout the house.  Most had nylon tree needles, I’m sure from both cats getting their fill.  Awesome.

To top it off, Jenn’s cat decided that it was time, finally, to pee on the new couch we just bought at Ikea.  We know without a doubt it was Jenn’s cat this time because there is no way my female cat could have peed all the way up the arm of the couch quite like that.  We had thought that he was just doing that to furniture that didn’t smell like him or something, but it seems to be… well, fairly arbitrary.  Again, awesome.

So things are pretty well coming together for a great holiday season. Granted, the Trans-Siberian Orchestra concert was a big plus to the start of the season, but now that the good stuff’s out of the way, we’re getting settled in for a good old-fashioned Griswold family Christmas.  Where’s the Tylenol?

media, music, activities comments edit

Trans-Siberian
OrchestraYesterday we went to the Rose Garden to see Trans-Siberian Orchestra in their 2007 tour.

Wow.

I mean, I’ve seen my share of concerts, but these guys really do it up right.  Lights.  Set pieces.  Fire.  Lasers.  Freaking snow.  Oh, yeah.

Best known for their rock and roll arrangements of classic Christmas music (you’ve most likely heard “Christmas Eve/Sarajevo 12/24”), TSO puts on a really awesome two-part show.

The first part of the show is their Christmas fare.  They use their music to tell the story of an angel crossing the world looking for something that represents Christmas.  Some of the music is the well-known stuff you’ve heard on the radio and some of it is original music and lyrics.  I won’t lie; I’m not as into the original stuff as I am with the updated arrangements on old standards, but it’s all really well done and the story is told very well.

The second part of the show is what they refer to as “play time.”  They break away from Christmas music and play other pieces, mainly rock and roll arrangements of other classical tunes.

Let me tell you something:  You have never heard “O Fortuna” or Beethoven’s Fifth until you’ve heard them done by Trans-Siberian Orchestra. The standard arrangements are, of course, classics, but the TSO versions are invigorating.  Life gets brought back to these pieces in a way it’s hard to describe.

What really made the show is that you could tell every one of the performers lives to do this.  They looked like they were having the time of their lives up there on stage, making music, having fun.  You wouldn’t imagine you could rock a violin, but Anna Phoebe, their violinist, does it.  Duelling electric guitarists show each other up on stage, the loser slumping his shoulders and pouting his way off stage.  A medley of fast-and-furious piano solos ends up with Vince Guaraldi’s “Linus and Lucy.”  Heads bang, hair is flipped, musicians charge through the audience.  The energy is high and every single one of the performers is almost literally glowing with the fun they’re having.

It’s a hell of a show.

If you get a chance to check them out, definitely do.  The music on CD is good, but it’s nothing compared to the live production.  I’ll be there again next year, no question about it.

GeekSpeak comments edit

I noticed, about a month ago, that whenever I would log in to Windows Live Messenger, I’d get a little toast popup telling me to verify my email address:

You need to verify your e-mail address with Windows Live Messenger.
Click
here.

I clicked, I followed the verification process, and I thought everything was cool.  Not so.  The prompt kept coming up.  On subsequent times I tried to verify my address, though, it would tell me that I didn’t need to verify.  What gives?

I had recently taken advantage of the “linked ID” feature of Windows Live IDs. The misleading thing here: I did need to verify an email address, just not the one I was signing in with.  Curiously, signing in with the other IDs didn’t prompt me to verify… but that’s neither here nor there.  After fighting my way through support for a month on this (and specifically asking them if it had to do with my linked IDs), it came back that, yes, it was something to do with one of the other accounts.

Anyway, if you’re getting prompted and you recently linked your IDs, it’s probably a problem with one of the linked accounts.  Make sure they’re allverified.

General Ramblings comments edit

Dad's Car Accident

Dad’s Car Accident

My dad was headed to work yesterday and hit an icy patch in the road. His car spun 180 degrees, went into the ditch, and hit a tree.

He’s okay, albeit on some serious pain killers and with some chipped vertebrae.  No one else was involved or injured and after some physical therapy and some time to rest up, he should be good as new.

Here are some pictures of what was left of his car. Absolutely totaled.  He had to climb out the passenger window because the frame was so bent up neither door would open.

Of course, the thing he seems to be most concerned with is that, somewhere in the chaos, he lost his glasses.  Heh.

gists, aspnet, dotnet comments edit

Let’s say you have some text on your web site that has an image inline. Something like this:

Fields with a ! icon indicate failed validation.

You’ve seen that before.  You’ve probably done that before.  Now let’s say you’re using ASP.NET themes and skins to control your look and feel, and that icon is different based on your theme.  It might change to be:

Fields with a ! icon indicate failed validation.

You could have some ASPX code that handles that with the SkinID of the image, right?

Fields with a <asp:Image ID="icon" runat="server" SkinID="validationIcon" /> icon indicate failed validation.

Okay, that works acceptably, provided your skin defines an Image that has a SkinID “validationIcon.”  But you’re a savvy ASP.NET developer and you know better than to put literal strings like that right in your web application - you put your strings in resx files and look them up at runtime so your app can be localized.  Now what?

There are a few ideas you could try, but they don’t work (or not well):

  • String.Format - You could leave a {0} in the page text and try to String.Format the image into place.  That might work if you weren’t skinning, but you need to take advantage of ASP.NET skins… so that won’t work.
  • Client-side script - You could try some client-side script to render the image to a hidden place on the page and then place it into a <span /> or something in in the instructions, but that’s kind of painful.
  • Break the text up into separate controls - You could make the text three controls: the text before the image, the image, and the text after the image.  This could become hard to manage from a localization perspective (what if there isn’t any text after the image?) and it’s not terribly flexible.

The answer: ParseControl.

The System.Web.UI.Page class has a ParseControl method on it that it inherits from TemplateControl.  You can use this to your advantage - just put the markup inline into your resource string and use ParseControl method to create a control hierarchy on the fly.  Then just swap the parsed control hierarchy into your page where you want the text to display. Put a Literal in your ASPX and do your string lookup…

<asp:Literal ID="pageText" runat="server" Text="<%$Resources: MyResources, PageText %>"/>

And in your resx file, put the entire text, including the image markup:

<data name="PageText" xml:space="preserve">
  <value>Fields with a &lt;asp:Image ID="icon" runat="server" SkinID="validationIcon" /&gt; indicate failed validation.</value>
</data>`

See how that looks just like ASPX page markup?  Perfect.  Now in the codebehind of your page class, replace the Literal with the control hierarchy that gets parsed from the text in that very Literal:

public partial class MyPage : System.Web.UI.Page
{
  protected void Page_Load(object sender, EventArgs e)
  {
    Control parsed = this.ParseControl(this.pageText.Text);
    Control parent = this.pageText.Parent;
    int index = parent.Controls.IndexOf(this.pageText);
    parent.Controls.AddAt(index, parsed);
    parent.Controls.Remove(this.pageText);
  }
}

In that example code, we:

  • Parse the text that got looked up from resources into a control hierarchy.  This lets us account for localization while still providing the inline themed icon we’re looking for.
  • Grab the parent of the original control.  This is important because you need to insert the parsed control hierarchy into the proper spot in the control tree.
  • Find the exact location of the original control in the parent’s control structure.  This tells us where to put the parsed control hierarchy.
  • Insert the parsed control hierarchy into the proper spot.
  • Remove the original control from the hierarchy - we’ve replaced it, so it’s no longer needed.

Pretty nifty, eh?  There are lots of other things you might want to consider if you do this, but I’ll leave them as “an exercise for the reader,” so to speak:

  • The example replaces the control with the parsed hierarchy; you might instead wish to add the parsed hierarchy as a child of the control you’re “replacing.”
  • If you use the same text twice in the same page, you may end up with control naming clashes; you might want to wrap the parsed control hierarchy in a naming container to avoid that.
  • You probably don’t want to repeat this code over and over in every page; you’d want to have a single service class that does this for you.

A tiny word of warning:  you probably don’t want to do this on every single string you localize. It’s not super expensive, but it isn’t necessarily “free,” either.  Here’s the timing from trace output - you can see the obvious difference in the amount of time the page Load event (where I’m doing this) takes vs. the other events.

Timings for parsing inline
controls.

It’s only ~0.01 seconds, but you wouldn’t want to, say, put this in the middle of a big databinding block.