Ok, I feel foolish for not having known this, but now I know it, and want to share. If you have some ASP.NET code that you want to comment out, you can just wrap the code with server side comments. They’re just like regular HTML comments, except the exclamation point has been replaced with the percent sign, i.e. <%– and –%>. So to comment out the following:
<asp:Panel runat="server" ID="Panel1" Visible="false">
<asp:Label runat="server" ID="firstNameLabel" AssociatedControlID="firstName" Text="First Name: " />
<asp:TextBox runat="server" ID="firstName" />
</asp:Panel>
Just surround the code with <%– and –%>, as below:
<%--
<asp:Panel runat="server" ID="Panel1" Visible="false">
<asp:Label runat="server" ID="firstNameLabel" AssociatedControlID="firstName" Text="First Name: " />
<asp:TextBox runat="server" ID="firstName" />
</asp:Panel>
--%>
Before learning this I would have changed all the ‘runat=”server” ‘ bits to ‘xrunat=”server” ‘, which is…ugly. I guess it’s never too late to learn new things.
Del.icio.us
digg
FURL
reddit
Technorati
Ma.gnolia
Stumble Upon
Bloglines
Very cool. I would usually do runat=”serverXXX”, which sounds a little dirty.