Комментарии Серверной стороны ASP.NET в <сценарии> Блок

Существует довольно хорошее учебное руководство для Вас .

В основном:

  1. Сумма веса всех чисел.
  2. Выбор случайное число меньше, чем тот
  3. вычитают веса в порядке, пока результат не отрицателен, и возвратите то число, если это.

8
задан Alex 22 September 2009 в 18:51
поделиться

5 ответов

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.

9
ответ дан 5 December 2019 в 12:10
поделиться

Вы также пробовали комментировать строки с помощью комментариев javascript? Очевидно, это должно сработать:

<script type="text/javascript">
<%--
// Comments that
// will not be rendered
//--%>
</script>

Взято из сообщения в блоге Скотта Гатри здесь .

2
ответ дан 5 December 2019 в 12:10
поделиться

You can add comments in javascript by making each line start with "//". Those survive through the ASP.NET engine just fine.

1
ответ дан 5 December 2019 в 12:10
поделиться

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.

1
ответ дан 5 December 2019 в 12:10
поделиться

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.

1
ответ дан 5 December 2019 в 12:10
поделиться
Другие вопросы по тегам:

Похожие вопросы: