Note that there are some explanatory texts on larger screens.

plurals
  1. PORazor Engine - How can I render different body tags based on different conditions?
    primarykey
    data
    text
    <p>Here is the code I currently have:</p> <pre><code>@{ if (Request.Browser.Browser == "IE") { if (Request.Browser.MajorVersion == 7) { &lt;body class="ie7"&gt; } if (Request.Browser.MajorVersion == 8) { &lt;body class="ie8"&gt; } if (Request.Browser.MajorVersion == 9) { &lt;body class="ie9"&gt; } if (Request.Browser.MajorVersion &gt; 9) { &lt;body&gt; } } else { &lt;body&gt; } } </code></pre> <p>Here is the error that it returns when the browser attempts to render it:</p> <blockquote> <p>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.</p> </blockquote> <p>What the heck? I was able to do this in the standard ASP.NET template syntax! Here's what that looked like:</p> <pre><code>&lt;% // Adaptation of paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/ if ( (Request.Browser.Browser == "IE") &amp;&amp; (Request.Browser.MajorVersion == 7) ) { %&gt;&lt;body class="ie7"&gt;&lt;% } %&gt; &lt;% if ( (Request.Browser.Browser == "IE") &amp;&amp; (Request.Browser.MajorVersion == 8) ) { %&gt;&lt;body class="ie8"&gt;&lt;% } %&gt; &lt;% if ( (Request.Browser.Browser == "IE") &amp;&amp; (Request.Browser.MajorVersion == 9) ) { %&gt;&lt;body class="ie9"&gt;&lt;% } %&gt; &lt;% if ( (Request.Browser.Browser == "IE") &amp;&amp; (Request.Browser.MajorVersion &gt; 9) ) { %&gt;&lt;body&gt;&lt;% } %&gt; &lt;% if (Request.Browser.Browser != "IE") { %&gt;&lt;body&gt;&lt;% } %&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload