in

Platinum Bay

Peace, Love and Visual Studio Team System

.NETicated

Easier ASP.NET Commenting

In my Visual Studio Tips and Treats talk, I discuss proper code commenting for ASP.NET pages. Let's review.

It is generally a bad idea to use regular HTML comments to comment out ASP.NET server and user controls. Why? Because the commented controls still be parsed and rendered. Imagine commenting out a large data grid, but still having all that content sent to the client. Worse yet is sensitive information that has been 'removed', but is still showing up in the client-side source.

Example:

<!--<asp:Label ID="Label1" runat="server" Text="SocialSecurityNumber" />-->

The recommended approach is to use server-side comments (Ctrl+K+C). Server-side comments prevent the commented code from being parsed and sent to the client.

Example:

<%--<asp:Label ID="Label1" runat="server" Text="SocialSecurityNumber" />--%>

Now for the good part. I just discovered, by accident, that you don't need to highlight the entire region you want commented. You can simple place the cursor inside the tag you want commented, and use the keyboard command Ctrl+K+C to comment, or Ctrl+K+U to uncomment. Up until now, I had either used the mouse or Shift+[Down|Up]Arrow to select the region I wanted to comment out.

Published Dec 23 2007, 03:00 PM by Steve
Filed under: ,

Comments

No Comments

Leave a Comment

(required )  
(optional )
(required )  
Add

About Steve

Steve Andrews has been working as a developer for more than 8 years. During this time, he has designed and developed applications in such widely varying areas as trust accounting, medical information management, supply chain management, and retail systems. He has firsthand developer experience with a variety of languages, including Java, VB, and .NET. Most recently, he has been immersed in SharePoint. He is currently employed at RDA Corporation in Philadelphia, PA, as a Software Engineer and a team member in the Architectural Guidance evangelism team. Steve is also an MTCS (x2), ICSOO, and .NET fanatic.
Powered by Community Server (Commercial Edition), by Telligent Systems
© Platinum Bay | Some Rights Reserved Creative Commons License

Disclaimer: The information in this weblog is provided "AS IS" with no warranties, and confers no rights. This weblog does not represent the thoughts, intentions, plans or strategies of my employer. It is solely my opinion. Feel free to challenge me, disagree with me, or tell me I'm completely nuts in the comments section of each blog entry, but I reserve the right to delete any comment for any reason whatsoever (abusive, profane, rude, or annonymous comments) - so keep it polite, please.