I have some buttons in my view.
i want to disable some of the buttons based on some condition from controller. is there any way to do that?
I have some buttons in my view.
i want to disable some of the buttons based on some condition from controller. is there any way to do that?
Model:
public class MyModel {
public bool SomeProperty { get; set; }
public bool AnotherProperty { get; set; }
}
Action:
public ViewResult Index() {
//strongly typed example
var model = new MyModel {
SomeProperty = true,
AnotherProperty = false
}
ViewData["Something"] = true; //view data example
return View(model);
}
View:
<button <%: Model.SomeProperty ? "disabled=\"disabled\"" : "" %>>some button</button>
<button <%: Model.AnotherProperty ? "disabled=\"disabled\"" : "" %>>Another button</button>
<button <%: ((bool)ViewData["Something"]) ? "disabled=\"disabled\"" : "" %>>Something</button>