ASP.NET MVC > Views - Razor Engine

Switch case conditional operator in ASP.NET MVC

How to perform switch case conditional operation in view?


It is similar to if, we just need to write switch statement. Notice how beautifully we are able to mix the C# and HTML code. 

@switch (fileName) 
{
case "itfunda":
<p>itfunda logo</p>
break;
case "dotnetfunda":
<p>dotnetfunda logo</p>
break;
default :
<p>no logo</p>
break;
}
 Views: 26335 | Post Order: 14



Write for us






Hosting Recommendations