asp.net.ph

Skip Navigation LinksHome > Getting Started > ASP.NET Syntax > ASP.NET Page Syntax > Server-Side Comments

Server-Side Comments

ASP.NET Syntax   ASP.NET Page Syntax


Allows you to include code comments in the body of an .aspx file. Any content between opening and closing tags of server-side comment elements, whether ASP.NET code or literal text, will not be processed on the server or rendered to the resulting page.

<%-- commented out code or content --%>

Remarks

ASP.NET server-side comment blocks have the same uses as traditional language-specific comment blocks, including documentation and testing.

Within <script runat="server"></script> and <% %> blocks, you can use comment syntax in the language that you are coding in.

A compilation error will occur if you use server-side comment blocks within <% %> blocks.

The opening and closing comment tags can appear on the same line of code or can be separated by many commented-out lines.

Server-side comment blocks cannot be nested.

Syntax Example

The below code snippet demonstrates an HtmlButton control that is commented out.

 <%-- <button runat="server" id="MyButton" onServerClick = "MyButton_Click">
            Click here for enlightenment!
      </button>
 --%>  
See Also

Introducing ASP.NET Web Forms



© 2025 Reynald Nuñez and asp.net.ph. All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note