为什么我不能在asp.net中注释掉一个updatepanel?

chi*_*leo 0 asp.net comments repeater

我做了一个空白页并添加了以下内容,从而产生了正确运行的页面:

    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
    </asp:UpdatePanel>
Run Code Online (Sandbox Code Playgroud)

然后我把它改成了以下内容:

    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <!--<asp:UpdatePanel ID="UpdatePanel1" runat="server">-->
    <!--</asp:UpdatePanel>-->
Run Code Online (Sandbox Code Playgroud)

为什么这会导致错误,说我不能在更新面板中有一个" - >"文字!?

谢谢!

cod*_*der 7

这是错的:

<!--<asp:UpdatePanel ID="UpdatePanel1" runat="server">-->
<!--</asp:UpdatePanel>-->
Run Code Online (Sandbox Code Playgroud)

这是对的:

<%--<asp:UpdatePanel ID="UpdatePanel1" runat="server">
    </asp:UpdatePanel>--%>
Run Code Online (Sandbox Code Playgroud)

编辑:

ASP.NET支持一个名为"服务器端注释"的鲜为人知的功能,您可以使用它来完全禁用页面中的代码/控件/ html.ASP.NET中的服务器端注释使用<% - - %>分隔

关键的区别在于,对于客户端注释,浏览器忽略了其中的内容.客户端注释中的代码/控件仍将在服务器上执行并发送到浏览器.因此,如果在其中导致服务器错误,它将阻止运行页面.