#DEBUG Preprocessor statements in ASPX page

Viewed 12347

I'm trying to use a preprocessor directive in an ASPX page, but the page doesn't recognize it. Is this just something I can't do?

Background: I'm trying to include the full version of jQuery in DEBUG mode (for, well, debugging =) ), and the minified version for release. I tried this, but I'm not terribly familiar with the ASPX <% syntax. Am I just fundamentally misunderstanding what this syntax does?

<% #if DEBUG %>
<script type="text/javascript" src="resources/jquery-1.3.2.js" />
<% #else %>
<script type="text/javascript" src="resources/jquery-1.3.2.min.js" />
<% #endif %>
8 Answers

Interesting difference here - using #if DEBUG in the aspx page pulls from the tag in the web.config, but when you use it in the code-behind, it pulls DEBUG from the constant from the build configuration in the project file. So they're actually accessing two different settings.

Thus, as far as I can tell, this isn't actually possible.

I had the same problem, I tried to solve it in both asp.mvc application and webform application. The #if debug always return true, it never takes into account the web.config compilation setting. I solved it in similar way to Syam advice posted in this post, but instead of static function I use astatcic variable as described here: http://www.psworld.pl/Programming/DebugDirective

Related