I am using MVC for my Project. I have Page in a view and the page has some buttons in it. I want to hide some of the buttons depending on a boolean condition.
How Can I achieve that?
You could use a view model containing a boolean property which should indicate whether a given section should be visible or not:
@if (Model.AreButtonsVisible)
{
<button>some button</button>
}
Another possibility is to write a custom HTML helper rendering those buttons which will take a boolean value indicating whether it should emit or not the corresponding HTML.
@if(condition){
<input type="button" value="the button"/>
}