6/02/2006

Diggety? And ClientID "Unmangling"

I noticed Digg was down this morning ("metropolitan network problems") so I missed my morning DiggFix.

But when I stopped back during lunch to check out some post about a new NanoCrystal Display technology, I got a laff from one comment:


"HOLY CRAP GUYS THIS IS IT. THIS IS THE REVOLUTION. IT STARTS NOW WTFOMGWTF!!!!!!!!WE COULD BEND THE TV WTFOMGWTF!!!!!!!! BEND IT BABY!! BEND IT LIKE BECKHAM!!!!!!!!OOOOOHHH YEAAHHHH!!!!!!!!!!! MY BENDY LAPTOP IS GONNA RUN FOOOOREVER!!!!!!!FUEL CELL BATTERY PLUS NANOCRYSTAL DISPLAY 4 LYFE MOTHER****** CRADLE 2 DA GRAVE BABYWTFOMGWTF!!!!!!!


This, folks is what happens to otherwise perfectly normal geeks who spend too much time on Digg. Their minds get DiggF*cked!

Sadly, there is no known cure.

ClientID Unmangler:



In other news, I've noticed that the concept of "not being able to get the eventual correct ClientId" of an element when using MasterPages is showing up on forums and newsgroup postings in ever - increasing numbers.

Let me give an example of one way to do this:


private string script = "[Label1ID].innerHTML = 'boo!';";
private string scriptKey = "hello";
private bool addScriptTags = true;
protected void Page_Load(object sender, EventArgs e)
{
script = script.Replace("[Label1ID]",Label1.ClientID);
ClientScript.RegisterStartupScript(this.GetType(), scriptKey, script, addScriptTags);

What this does, very simply, is inject a javascript variable into the page with the "real" ClientId including all the MasterPage and any other namingcontainer mangling that ASP.NET uses to disambiguate control id's.

( boy, that was a mouthful. I better look that one up in my Hillbilly SpellChecker.)