How to implement checkbox list in ASP.NET MVC?

Just migrated from WebForms to MVC and replaced various user interfaces. Not sure how WebForms CheckListBox is implemented, is there a jQuery plugin or a basic example of this?

+3
source share
1 answer

Depending on your need for jQuery, a template like this I usually use. (You should be able to connect jQuery events to this, I save this until the base template.)

<div class="checkBoxList"><!-- This class usually defines a max-height and overflow -->
    <% foreach (MyObject o in Model.MyObjects) { %>
        <input type="checkbox" name="myObjectSelections" 
            value="<%=o.Value%>" /><br />
        <%=o.Text%>
    <% } %>
</div>

(I can clarify this answer after a couple of hours, as soon as I am at work, and look at my real code for this, but it should start working.)

bool myObjectSelections.

+4

Source: https://habr.com/ru/post/1739839/


All Articles