有AsIFnet标记的#IF DEBUG吗?

我可以在asp.net页面标记中做这样的事情,基于“定义DEBUG常量”设置?
#IF (DEBUG) THEN
  <asp:TextBox ID="TextBox1" runat="server">You're in debug mode</asp:TextBox>
#END IF

解决方法

我可以得到的关闭是:
<asp:Literal id="isDebug" runat="server" />
<script runat="server">
    void Page_Load()
    {
#if DEBUG
        isDebug.Text = "You're in debug mode";
#endif
    }
</script>

如果你想在你的Page_Load()事件中有其他东西,这将给你的问题;上面的文字代码只有在页面/控件没有代码的情况下才有效。

如果我需要这样做,我会将上述代码封装到用户控件中,并将该控件包含在感兴趣的页面中。

我的测试用户控件看起来像这样:

<%@ Control Language="C#" AutoEventWireup="true"  %>
<asp:Literal id="isDebug" runat="server" />
<script runat="server">    
    void Page_Load()    
    {
#if DEBUG        
        isDebug.Text = "You're in debug mode";
#endif    
    }
</script>

相关文章

这篇文章主要讲解了“WPF如何实现带筛选功能的DataGrid”,文...
本篇内容介绍了“基于WPF如何实现3D画廊动画效果”的有关知识...
Some samples are below for ASP.Net web form controls:(fr...
问题描述: 对于未定义为 System.String 的列,唯一有效的值...
最近用到了CalendarExtender,结果不知道为什么发生了错位,...
ASP.NET 2.0 page lifecyle ASP.NET 2.0 event sequence cha...