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;
}
pixelmeow
  • 654
  • 1
  • 9
  • 31
salar
  • 710
  • 3
  • 6
  • 22
  • Your checkboxes don't have a `value` attribute so nothing post back –  Mar 02 '15 at 21:08

1 Answers1

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.

Community
  • 1
  • 1
CodeBob
  • 775
  • 7
  • 14