Null Pointer
Null Pointer

Reputation: 9289

Hide check box from controller-MVC

How can i hide/show a check box based on a value obtained from controller. I am using the given below code for check box

   <%= Html.CheckBoxFor(m =>m.IncludeCallWithNoAgents) %>

Upvotes: 1

Views: 335

Answers (1)

Darin Dimitrov
Darin Dimitrov

Reputation: 1038710

Your view model could contain a property which would be set by the controller action and which should indicate whether this checkbox should be shown or not:

<% if (Model.ShouldShowCheckBox) { %>
    <%= Html.CheckBoxFor(m => m.IncludeCallWithNoAgents) %>
<% } %>

Upvotes: 3

Related Questions