I'm working on an ASP.NET MVC 5 application. It contains a multi step wizard.
Here is my model,
public interface IWizardViewModel
{
}
[Serializable]
public class WizardStep1ViewModel : IWizardViewModel
{
public string ProductName { get; set; }
public bool IsAvailable { get; set; }
}
[Serializable]
public class WizardStep2ViewModel : IWizardViewModel
{
public int Id { get; set; }
public string Name { get; set; }
}
Here is my partial view for wizard step 1,
@Html.TextBoxFor(i => i.ProductName, new { @class = "form-control", @id="txtName", placeholder = "Product Name" })
@Html.CheckBoxFor(i => i.IsAvailable, new { @id = "chkIsAvailable" })
I'm trying to get the checkbox value in my controller,
[HttpPost]
public ActionResult Create([Deserialize] WizardViewModel wizard, IWizardViewModel step, WizardStep1ViewModel wizardStep1, FormCollection formCollection)
{
var isAvailable = formCollection["IsAvailable"];
}
My model object wizardStep1 always returns false value for IsAvailable and formcollection returns "False, true, false".
How do I get my checkbox value in controller?
Aucun commentaire:
Enregistrer un commentaire