I am using Identity 2.0 and in my ApplicationUser I have the following:
ApplicationUser.cs
public class ApplicationUser : IdentityUser
{
public string FirstName { get; set; }
public string LastName { get; set; }
//other things omitted for brevity
}
In my view I have the following simplified version:
@model ApplicationUser
@using (Html.BeginForm("Details", "Admin", FormMethod.Post, new { @class = "form-horizontal", role = "form" }))
{
<dl class="dl-horizontal ">
<dt>
@Html.DisplayNameFor(model => model.FirstName)
</dt>
<dd>
@Html.DisplayFor(model => model.FirstName)
</dd>
<dt>
@Html.DisplayNameFor(model => model.LastName)
</dt>
<dd>
@Html.DisplayFor(model => model.LastName)
</dd>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Save" class="btn btn-default" />
</div>
}
My controller
[HttpPost]
public async Task<ActionResult> Details (ApplicationUser model)
{
//do checks on which items have been selected
return View();
}
I want to add checkbox next to each of the labels, and in my POST action I want to be able to see which have been selected. Eg. FirstName = checked, LastName = notChecked or anything similar. Which approach should I take? I have tried checkboxfor, but without any success.