tags:

views:

27

answers:

1

I'm starting to play around with MVC. I did the NerdDinner walkthrough and now I'm creating a simple project that displays the products in the Northwinds database. I have a details view, a create view, and an edit view. I figured out how to display a checkbox for the boolean property, "Discontinued", but I want the control to be disabled on the details view (since the edit view is used for editing). This is what I have:

<div class="display-label">Discontinued: <%: Html.CheckBoxFor(Function(model) model.Discontinued)%></div>

I'm not sure how to get to or set the enabled property of the checkbox. (I suppose I could do it using javascript, but I'm thinking there is a better way). Thanks for the help.

+2  A: 

You want to do <%: Html.CheckBoxFor(Function(model) model.Discontinued, new { disabled = disabled })%>

to pass in HtmlAttributes in the constructor.

Yngve B. Nilsen