有AsIFnet标记的#IF DEBUG吗?

前端之家收集整理的这篇文章主要介绍了有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>
原文链接:https://www.f2er.com/aspnet/254839.html

猜你在找的asp.Net相关文章