Here is the code I currently have:
@{
if (Request.Browser.Browser == "IE") {
if (Request.Browser.MajorVersion == 7) { <body class="ie7"> }
if (Request.Browser.MajorVersion == 8) { <body class="ie8"> }
if (Request.Browser.MajorVersion == 9) { <body class="ie9"> }
if (Request.Browser.MajorVersion > 9) { <body> }
} else {
<body>
}
}
Here is the error that it returns when the browser attempts to render it:
Parser Error Message: The code block is missing a closing "}" character. Make sure you have a matching "}" character for all the "{" characters within this block, and that none of the "}" characters are being interpreted as markup.
What the heck? I was able to do this in the standard ASP.NET template syntax! Here's what that looked like:
<% // Adaptation of paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/
if ( (Request.Browser.Browser == "IE") && (Request.Browser.MajorVersion == 7) ) { %><body class="ie7"><% } %>
<% if ( (Request.Browser.Browser == "IE") && (Request.Browser.MajorVersion == 8) ) { %><body class="ie8"><% } %>
<% if ( (Request.Browser.Browser == "IE") && (Request.Browser.MajorVersion == 9) ) { %><body class="ie9"><% } %>
<% if ( (Request.Browser.Browser == "IE") && (Request.Browser.MajorVersion > 9) ) { %><body><% } %>
<% if (Request.Browser.Browser != "IE") { %><body><% } %>