ASP.NET MVC > Views - Razor Engine

If condition in Razor view engine in ASP.NET MVC

How to perform if conditional operation in view?

@if (fileName == "itfunda")
<p>The file name is not ITFunda</p>
<p>Sorry, it is DotNetFunda</p>

Notice that @ character is just before the first line of the conditional statement, else doesn’t have @ as the Razor markup automatically detects the starting and ending if block and assumes that else is the part of if not the HTML syntax. 

 Views: 51089 | Post Order: 13

Write for us

Hosting Recommendations