Существует довольно хорошее учебное руководство для Вас .
В основном:
You can add the comment no problem.
Visual Studio is stupid and doesn't recognize the ASP <%-- Comment %> tags in JS. Your page will still compile fine.
As mentioned in another answer, using //<%-- Comment %> will hide your comments (but leave the //).
Also, be careful of ASP.NET's habit of ignoring whitespace or line breaks around ASP-wrapped code:
//<%-- Comment %>
var whatever = '';
May become:
//var whatever = '';
at run time.
Вы также пробовали комментировать строки с помощью комментариев javascript? Очевидно, это должно сработать:
<script type="text/javascript">
<%--
// Comments that
// will not be rendered
//--%>
</script>
Взято из сообщения в блоге Скотта Гатри здесь .
You can add comments in javascript by making each line start with "//". Those survive through the ASP.NET engine just fine.
Server tags does work inside aspx javascript tags. But visualstudio doesn't get it, it gives you lots of errors, but if you run the page it will work.
Its the same if you do serverside inside a html tag.
Shouldn't you ideally be decoupling your JS code from ASPX as much as possible? The bulk of your JS code that is complicated enough to deserve commenting should reside in stand-alone JS files. You should have the bare minimum amount of code on the ASPX side and simply invoke JS functions etc. from the external JS files.