Using the #if DEBUG Conditional Compilation Statement on an aspx Page

I am trying to do something like this on an aspx page:

<head runat="server">
    <% #if DEBUG %>
        <script src="jquery-1.3.2.js" type="text/javascript"></script>
    <% #else  %>
        <script src="jquery-1.3.2.min.js" type="text/javascript"></script>
    <% #endif %>
</head>

I get the error message "Preprocessor directives should appear as the first character with no spaces in the string." How can i do this?

+3
source share
2 answers
<head runat="server">
  <% 
    #if DEBUG
  %>
    <script src="jquery-1.3.2.js" type="text/javascript"></script>
  <%
    #else
  %>
    <script src="jquery-1.3.2.min.js" type="text/javascript"></script>
  <%
    #endif
  %>
</head>

Works for me - note that this is based on the attribute value debugin the element of <compilation>the web.config file.

Change response to comment

Ah, so you also add controls to the head through code? Then you probably have to add this dynamically and from the code. Besides,

-, IntelliSense Visual Studio, , , :

VS2008 SP1 "-vsdoc.js" IntelliSense

jquery-1.3.2.min-vsdoc.js VS .

+6

:

<head runat="server">
    <asp:PlaceHolder runat="server">
    <% 
#if !DEBUG 
    %>
    <meta http-equiv="X-UA-Compatible" content="IE=9" />
    <% 
#else 
    %>
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <% 
#endif 
    %>
    </asp:PlaceHolder>
</head>
+1

Source: https://habr.com/ru/post/1736139/


All Articles