My Resume

  • My Resume (MS Word) My Resume (PDF)


  • Microsoft Most Valuable Professional
  • INETA Community Champion
  • Leader, NJDOTNET: Central New Jersey .NET User Group

Saturday, February 16, 2008

Server-Side ASP.NET Variables Meet Client-Side JavaScript

I came across Rick Strahl's awesome blog post tonight about something that's consistently been a thorn in my side: I've got an ASP.NET variable/value (say, a control's ClientID, or "a $Ch~!'unk of T==ex_t '1'$li%20ke"`th"is~!") that I want to populate a JavaScript variable with on the client side.  My first instinct has always been to just do a handy little in-line <%= MyVariable %> and for the most part that usually works... for the most part.  But, there are plenty of cases - such as special characters, encoding issues, or simply the fact that you're trying to mix inline code with external (aka - static) script files - where this solution won't work.  However, Rick's nice little class takes a stab at addressing that problem, and I think it does it pretty darn well.  I'm looking forward to trying this out in my next project.

Keep 'em coming, Rick. :)