Lord Vermillion Lord Vermillion - 3 months ago 17
C# Question

Razor if-statement using c# method

I have a C# MVC project using Razor for views.

In my _Layout.cshtml file i want to hide menuoptions based on bools in a helper class.

@using Project.HelpMethods;

<li id="menuOptionAppleIds">
@Html.ActionLink("A", "A", "Home")
</li>


How do i call a statis bool method in HelpMethods and use in as the expression in an if statement around the
<li>
element?

Answer
@if (Project.HelpMethods.IsOk())
{
    <li id="menuOptionAppleIds">
        @Html.ActionLink("A", "A", "Home")
    </li>
}
Comments