I am using jquery plugin to add checkbox in dropdown list.
I do not include $(document).ready, dropdown list works as single selection and I can get value in model.WorkplaceID in control`enter code here`ler. but if I include $(document).ready, its showing blank in model.WorkplaceID in controller. On using $(document).ready, items are selected in span. I guess view in not able to set that value in UserModel model. How can i pass value in controller???
My code goes like this.
$(document).ready(function () {
$("#WorkplaceID").dropdownchecklist();
});
--To display control in view
@model Kats.DAL.UserModel
@{
ViewBag.Title = "Createuser";
Layout = "~/Areas/SuperAdmin/Views/Shared/_Layout.cshtml";
List<SelectListItem> WorkPlaces = (List<SelectListItem>)ViewBag.WorkPlaces;
}
<li>
@Html.LabelFor(m => m.WorkplaceID, "Workplace:")
@Html.DropDownList("WorkplaceID", WorkPlaces)
@Html.HiddenFor(m => m.Workplace)
</li>
$(document).ready(function(){
$("#WorkplaceID").dropdownchecklist();
});
-- To bind jquery plugin for check box selection in dropdown
Here, if I don't include $(document).ready, dropdown list works as single selection and I can get value in model.WorkplaceID in control`enter code here`ler. but if I include $(document).ready, its showing blank in model.WorkplaceID in controller. On using $(document).ready, items are selected in span. I guess view in not able to set that value in UserModel model. How can i pass value in controller???
--Get value in controller for db related action
[HttpPost]
public ActionResult Create(UserModel model)
{
String wp == model.WorkplaceID;
}
What I have tried:
On checking DOM, I found out that on multiple selection, item is being created on span. Is it the m.Workplace is not able to read value of span??