我想做这样的事情
<# if ANYPREPROCESSORCONSTANT #>
<%--
<# endif #>
是否可能(我想有条件地放一个asp.net COMMENT,我不想调用一个方法条件)?
更新:似乎不可能最终没有人能给出任何正确答案:)
答案 0 :(得分:2)
你可以这样做:
<% #if DEBUG %>
<div id="debug"></div>
<% #else %>
<div id="release"></div>
<% #endif %>
虽然我认为它不太可读......只在需要时才使用它!
答案 1 :(得分:1)
是的,您在web.config中为Web站点项目定义了编译器常量,如下所示。注意,注释必须完全包含在#if ...#end if construct中。否则,你正在评论#end if。
<system.codedom>
<compilers>
<compiler language="c#;cs;csharp" extension=".cs" type="Microsoft.CSharp.CSharpCodeProvider,System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" warningLevel="4">
<providerOption name="CompilerVersion" value="v3.5"/>
<providerOption name="WarnAsError" value="false"/>
</compiler>
<compiler compilerOptions="/d:DEBUG,TRACE,DEBUG_SURVEYCODE,GPT,TRACE_ARGS,TRACE_ARGS_OUTPUT,TRACE_FILES,DEBUG_USER" language="vb;vbs;visualbasic;vbscript" extension=".vb" type="Microsoft.VisualBasic.VBCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>
</compilers>
</system.codedom>
<% #if TRACE_ARGS_OUTPUT %>
<!-- this traces output comment -->
<% #end if %>
<% #if TRACE_ARGS_OUTPUT = FALSE %>
<!-- this does not output comment -->
<% #end if %>
答案 2 :(得分:0)
既然你说过设计时间,我假设你指的是Server Control Design Support?
你必须在你的设计时代码中处理条件......
#if SOMEDEFINE
DoSomething();
#ENDIF