How to comment out an ASP.NET server control – doesn’t work – level 100

I was performing some testing, so I commented out a bit of my ASP.NET markup with <!– –> because, after all, I’ve used that for years, right?  Well, it took me just a sec to figure out that the server control was still being executed and that the <!– was just rendered before it on the client.  The important bit:  <!– is HTML syntax, not server-side syntax.  If you want to comment out a server control, use the following syntax:


<%–   <asp:Button . . . . />  –%>


 

This entry was posted in Uncategorized. Bookmark the permalink. Follow any comments here with the RSS feed for this post.

7 Responses to How to comment out an ASP.NET server control – doesn’t work – level 100

  1. Timothy says:

    Thanks so much.

    Very helpful

  2. Paul says:

    using <%— —%> is for many lines, How would you comment out just one line of code?

  3. Steve Branson says:

    Perfect solution to an annoying problem. Thanks! (found with google)

  4. Ken Jackson says:

    I actually googled for this Jeff and got your page. Isn’t that cool! Thanks for the tip…

  5. Jason Hoekstra says:

    Great tip … works for me. :)

  6. Michael Polo says:

    I think it will only comment out one control at a time….

  7. saurabh says:

    this is really cool . i too saw this behavior..

    Saurabh

Leave a Reply