Reputation: 5424
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?
Upvotes: 0
Views: 669
Reputation: 771
@if(Helper.ShowMenuOption(x))
{
<li id="menuOptionAppleIds">
@Html.ActionLink("A", "A", "Home")
</li>
}
You can use if-statements and method calls in razor as in every other C# file. The difference is to ad @symbol before the c# code
Upvotes: 1
Reputation: 24903
@if (Project.HelpMethods.IsOk())
{
<li id="menuOptionAppleIds">
@Html.ActionLink("A", "A", "Home")
</li>
}
Upvotes: 4