With RazorViewEngine, I can do this:
if (somecondition) {
some stuff
}
but I can\'t seem to do this (Razor ge
You can create a custom MVC Helper method. For with you create a public static class MyRenderHelpers in namespace System.Web.Mvc.Html
and write a method Html.
namespace System.Web.Mvc.Html
{
public static class MyRenderHelpers
{
public static MvcHtmlString Html(this HtmlHelper helper, string html, bool condition)
{
if (condition)
return MvcHtmlString.Create(html);
else
return MvcHtmlString.Empty;
}
}
}
Now you can use this extension method in your razor view:
@Html.Html("", somecondition)