comments in C# use two forward slashes.
i believe this should work:
<% // Some comment %>
Main Topics
Browse All TopicsIn the old asp days,
<% ' a comment %>
could appear anywhere in the <body> of an .aspx file and it would be invisible to a "view source". Is there a way to do this same thing in .NET (I'm using c#).
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
roricka: probably didn't work because of a space after the first % character.
You shouldn't use the // comment in the page layout for several reasons:
1. It doesn't block the sequence %> which means you can't surround wider blocks of code
2. It makes your ASPX code language-dependent, which it doesn't need to be
3. The <% // comments don't work around tags, such as <asp:Button>
4. The use of <% blocks makes the ASPX code unreadable.
I didn't request the points and I intentionally did not instruct the author to act in any particular way.
Regarding "your points", my suggestion which came first was a) standard, b) documented and c) correct. The only issue was the author had typed it in wrong, not anything wrong in the suggested solution, so let's not call them "your points" if you don't mind.
i don't really want to argue about who's code was better because i don't doubt that your reasoning is correct. but at the same time, the author must've tried my code with success or else he/she would not have accepted.
i think an assist would be more fair seeing as he/she DID accept my answer and not yours.
secondly, if he/she decided to throw some server-side code into the equation... it wouldn't work with your example.
you might argue that that type of thing was never suggested, but then i could argue that putting the comment into a "block" wasn't either.
Now, now.
Actually, the idea of having language-independent syntax is what I was originally looking for (though didn't specify), and when it appeared as if only the "//" delimiter worked, I scratched my head, but decided it DID satisfy my original request. Had I not been so careless in trying the "--" syntax, I would have split the points.
BTW, for some reason, I can't get to the community support zone w/o pinning my CPU cycles (and on 2 different machines!)
When that calms down, I do plan on splitting the points among all the solutions that satisfied my original question. (That's the way I always do it -- at the point I review the submissions, I don't just give to the first person, but to everyone who satisfied the criteria w/original suggestions.)
That said, it appears that using the "--" approach exclusively in the future is the way to go.
Thanks all.
amabog (roricka)
what i meant in mentioning server-side was:
<%--
comment
Response.Write("can't be done");
--%>
<%
// comment
Response.Write("can be done");
%>
it's just more efficient in my opinion than doing this:
<%--
In the code snippet below, I'm going to Write something to the window.
--%>
<%
Response.Write("something to the window.");
%>
still though... i learned a lesson on commenting with <%-- .. i honestly didn't know how to do that, so thanks.
roricka... thanks for the split
The typical use of the <%-- comment block is to wrap existing markup, for example the original page might have:
<p><%
/* The next line does ......
and some more comment */
Response.Write("Some content");
%></p>
Obviously, the typical page would be more complex. You can use a server-side comment to wrap the complete set:
<%--
<p><%
/* The next line does ......
and some more comment */
Response.Write("Some content"); %></p>
--%>
Which you can't do with an embedded code comment.
The biggest limitation is that none of the ASP.NET comment conventions allow proper comment nesting, but the server-side comment is closest to it.
yeah, .NET can act a little fishy when it comes to certain things. eventhough the general markup of an aspx page seems to follow XML conventions, you couldn't do something like this without an error:
<asp:Table id="theTable" runat="server">
<asp:TableRow blah blah>blah blah blah</asp:TableRow>
<!--
this is how you comment XML... it'll break your code though if it's in the middle of a .NET control
-->
</asp:Table>
Business Accounts
Answer for Membership
by: SteveH_UKPosted on 2008-03-06 at 12:19:01ID: 21064263
You can use a similar tag in ASP.NET
/en-us/lib rary/4acf8 afk.aspx
<%-- comment here --%>
See http://msdn2.microsoft.com