0

I have an Enum list. I create these check boxes with the Enum list dynamically.

Here is the Enum list:

[LocalizableDescription(@"BankPos", typeof(Resources.DisplayNames))]
BankPos = 1,
[LocalizableDescription(@"PrarkingPlace", typeof(Resources.DisplayNames))]
PrarkingPlace = 2,
[LocalizableDescription(@"OutdoorPlace", typeof(Resources.DisplayNames))]
OutdoorPlace = 4`

I created the check box with foreach in Html tag .

Here are the check boxes:

<div class="checkbox-container">
    <% foreach (var feature in Model.Features)
        {%>
            <label>
                <input type="checkbox" name="q5" />
                <span><%= feature.Text %></span>
            </label>  
        <%} 
    %>
</div>

Up to here every thing is fine. My check boxes are create in correctly .

My problem is, how can I pass these check box values into controller?

As I said I want to pass them multiple.

Here is my controller

[HttpPost]
public ActionResult Review(ReviewMemberRatingViewModel model, HttpPostedFileBase picUpload)
{
  return null;
}
1
  • Your checkboxes don't have a value attribute so nothing post back Commented Mar 2, 2015 at 21:08

1 Answer 1

1

You need to include the checkboxes in your model, and bind the values to them. So when you change a value on the model, it will be available in your action result. You could generate your inputs with numerical indexes or there is a great example of what you are doing while taking it a step further with an editor template here.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.