#DEBUG Preprocessor statements in ASPX page

前端 未结 8 1075
滥情空心
滥情空心 2020-12-29 22:09

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 inclu

8条回答
  •  攒了一身酷
    2020-12-29 22:41

    To me the most elegant solution would be to simply define a field in code-behind with preprocessor directives and then check for its value from the aspx page.

    In code-behind:

    public partial class WebClient : System.Web.UI.Page
    {        
    #if DEBUG 
        public bool DebugMode = true;
    #else
        public bool DebugMode = false;
    #endif
    }
    

    Aspx page:

    <%if(this.DebugMode){%>
        
    
                                     
                  
提交回复
热议问题