New to Telerik UI for ASP.NET AJAX? Download free 30-day trial

Commenting HTML in Web Forms

DESCRIPTION

When you want to exclude part of your mark-up page and code definition, you should avoid using the following approach:

<!-- <asp:Button ID="Button1" runat="server" Text="Click" /> -->

The HTML in this case is still rendered on the page:

<!-- <input type="submit" name="Button1" value="Click" id="Button1" /> -->

This may lead to unpredictable issues and interfere with your script logic. Also, any server-side evaluation code inside the comments is still being executed.

SOLUTION

Instead, you can use the dedicated server-side comments of ASP.NET. This way the content inside the commented area won't be rendered at all:

<%--<asp:Button ID="Button1" runat="server" Text="Click" />--%>
In this article
Not finding the help you need? Improve this article