views:

217

answers:

3

In my page source I put: <!-- A comment -------->

and ASP.Net converts it to: &lt;!-- A comment --------&gt;

so by the time it gets to the browser, my comment is visible.

It doesn't do it to all comments and if I add in another comment it sometimes makes the comment go away.

Anyone seen this before? How can I fix it?

+2  A: 

Try putting an space before -->. It guess this might help. I haven't had such a problem before though.

It's a good practice:

  • not to have -- in comments
  • begin your comments with <!-- without more dashes
  • end your comments with --> without more dashes
Mehrdad Afshari
DanBrad
ASP.NET parser **does** care about HTML. It parses it on the server to some level. This is how it handles runat="server" tags.
Mehrdad Afshari
Yep, I get that I guess I expected it to just ignore anything it doesn't understand. Global search and relace here I come.Thanks for the response.
DanBrad
It's not just a matter of best practice: getting the wrong number of -- tokens in HTML as above (or in XML, using any -- other than -->) is invalid and can cause parsers (and even sometimes browsers) to choke. Avoid.
bobince
+1  A: 

Please check this page about comments and see if it helps.

Shoban
A: 

Hi,

Response.Write("<!--");

rest of html?

Resonse.Write("-->");

Younes