Reputation: 55449
For javascript
comments, I usually try to follow something similar to these guidelines. However, the Razor engine seems to throw up when it sees stuff like this in the cshtml
file:
/**
* This is my function.
* @param parm1 this is first parameter
* @param parm2 this is second parameter
*/
The @ sign seems to cause parser errors, since that's a special character in Razor. Anyway, I just wondered what other people are doing. I know I could probably use Razor comments and do something like this:
@*param parm1 this is first parameter *@
But that just feels wrong on so many levels.
Upvotes: 4
Views: 2286
Reputation: 9
The comments for Javascript style / * comment * / goes under the script section. ie < script > /* comment * / < / script >, the comment style / * comment * / is not valid under razor. at the HTML code, you could use < ! -- comment -- >, under the Razor code you could use the @* comment *@
Here is an example: .... Razor file ..... else { No Results. }
@* razor comment *@
<!-- html comment -->
<p>
@if (ViewData["parent"] != null && !HasRole(Site.Enti))
{
// another type of comment with Razor
if (theParent.Parent == null)
{
@Html.ActionLink("Up One Level", "index", "")
}
else
{
@* another valid razor comment *@
@Html.ActionLink(
"Up One Level",
"index",
new { controller = "", id = theParent.Parent.SchoolGroupId })
}
}
<script>
/*
javascript comment
*/
</script>
........ Hope this help
Upvotes: -1
Reputation: 17288
Try this:
/*
* This is my function.
* @@param parm1 this is first parameter
* @@param parm2 this is second parameter
*/
To write @
you just need to repeat it @@
in Razor view.
Upvotes: 5