Skip to main content
 首页 » 编程设计

c#之如何在 asp.net 中呈现之前删除 html 注释标记

2024年02月24日12jirigala

我正在使用一些组件。页面渲染时,组件生成 html 评论标签。如果我在一页上使用此组件 10 次,则插入 html 注释 10 次。

如何在渲染页面前去除html注释标签?

请您参考如下方法:

使用服务器端注释:

<%-- 
    Commented out HTML/CODE/Markup.  Anything with 
    this block will not be parsed/handled by ASP.NET. 
 
    <asp:Calendar runat="server"></asp:Calendar>  
 
   <%# Eval(“SomeProperty”) %>      
--%> 

或者只在 Debug模式下渲染评论

#if DEBUG 
// Add my comment for debug only 
#endif