C# and ASP.NET MVC: Using #if directive in a view

前端 未结 7 2158
不知归路
不知归路 2020-12-03 04:05

I\'ve got a conditional compilation symbol I\'m using called \"RELEASE\", that I indicated in my project\'s properties in Visual Studio. I want some particular CSS to be app

7条回答
  •  误落风尘
    2020-12-03 04:59

    In your model:

    bool isRelease = false;
    
    <% #if (RELEASE) %>
        isRelease = true;
    <% #endif %>
    

    In your view:

    <% if (Model.isRelease) { %>
        
    Banner text here
    <% } else { %>
    Banner text here
    <% } %>

提交回复
热议问题