Use Comments in Asp.Net MVC Razor View Example

  Total Views : 1878
  Comments : 0
 
  Keywords : How to write comments in asp.net mvc razor view, Define comments in razor view, Asp.net mvc comments in razor view

Commenting in Razor view is little different than c# comments. In C# we use (“//") for commenting but in Razor we will define comments like ("@*  *@"). 

Syntax for Commenting in Razor View

The syntax of comments in asp.net razor view will be like as shown below 

 

@* This is a Razor multiline comment *@

This razor view syntax (“ @*  *@") tell that code inside this should be ignore from being executed. This syntax is common for both vb.net and c# language using Razor. 

Shortcut to Comment Block

The shortcut for Razor Commenting are similar to C# shortcut that would be like as shown 

 

Comment the block - ( Ctrl E, C)

Uncomment the block - ( Ctrl E, U)

 

Following examples will show how to use razor comments in asp.net mvc applications

Example1

Following example shows how to use comments in mvc razor view 

 

<table>

<tr>

<td>DisplayName</td>

@*<td>@Html.DisplayName("Displayname")</td>*@

</tr>

</table>

Example2

Following is another example to use comments in mvc razor view 

 

This way we can use comments in razor view applications in asp.net mvc.

 Comments (0)

Be the first to give your valuable feedback

Leave a comment

  • Default Tutlane User