Just came across this code which I thought looked remarkably clean, considering how bad this type of thing could normally turn out.

This is including a small inline javascript at the tail of the layout. A dictionary in viewdata contains any number of key/value pairs that are passed to Omniture.

<viewdata OmnitureValues="Dictionary[[string, object]]"/>
<script type="text/javascript" language="JavaScript" src="http://www.example.com/include/js/s_code.js"></script>
<script type="text/javascript" language="JavaScript">
if (typeof s != "undefined")
{
# if (OmnitureValues != null)
# {
#   foreach (var val in OmnitureValues)
#   {
      s.${H(val.Key.ToLowerInvariant())} = "${H(val.Value)}";
#   }
# }

/************* DO NOT ALTER ANYTHING BELOW THIS LINE ! **************/
var s_code=s.t();if(s_code)document.write(s_code) }//
</script>

The lines starting with hash (#) marks are server-side code. The innermost line ends up being written out in the script once for each key/value pair. The thing I thought was so striking was how I scanned and grokked what the function was doing before I even realized I was looking at a mix of inline javascript and csharp.

So good job to the programmer that did this one. :)