I got sick of all my jscript social widget/analytics initialization cluttering my debug output while testing my Asp.Net webforms page locally. So I tried this in my HTML markup:
<script>
if (<%= !Request.IsLocal ? "true" : "false" %>) {
This actually emits correct jscript code ("if (true)") with no run-time errors but Visual Studio doesn't like it. I'm getting a syntax error on the closing ')'. Definitely don't like seeing compile errors, even if they're bogus, every darn time I compile.
I changed it to compare strings, like
if ("<%= Request.IsLocal %>" === "False") {
Which works and emits code like 'if ("True" === "False")', but... that just grates on my nerves and looks ugly. Is this just a Visual Studio weirdness, or is there a better way to use asp.net server boolean values in jscript conditionals?