Hi all
I am passing multiple parameter values from a controller to view through json and
all textbox and DDL values binding except Checkbox values.
tell me the mistake where i missed
What I have tried:
Controller :-
------------
public ActionResult GetAdministratorDetails(string AdministratorID,AdministratorsModel Model, string Command)
{
try
{
ModelState.Clear();
AdminControllerPageObject.GetAdministratorDetails(AdministratorID,Model);
AdminControllerPageObject.GetAdministratorBankDetails(AdministratorID, Model);
List<AdministratorInformation> AdministratorNameList = AdminControllerPageObject.GetAdministratornamesInfo();
SelectList Names = new SelectList(AdministratorNameList, "IdRef", "Name");
Model.AdministratorNameDetails = Names;
var result = new {IdRef=Model.IDreference,Name=Model.Name, MealEntertainmentCard=Model.MealEntertainmentCard, LivingExpensesCard=Model.LivingExpensesCard};
return Json(result, JsonRequestBehavior.AllowGet);
}
catch (Exception ex)
{
logger.Debug(ex.Message.ToString());
return Json("");
}
}
In ViewPage :-
------------
$(document).ready(function () {
$('#AdministratorName').change(function () {
$.ajax({
type: "POST",
url: '@Url.Action("GetAdministratorDetails", "Admin")',
data: { AdministratorID: $('#AdministratorName').val() },
datatype: "json",
traditional: true,
success: function (data) {
$(MealEntertainmentCard).val(data.MealEntertainmentCard) $(LivingExpensesCard).val(data.LivingExpensesCard);
}
});
});
});
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
@Html.CheckBoxFor(m => m.MealEntertainmentCard, new { @class = "input-text chkb"})
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
<input type="text" id="meal-entertainment-card" class="form-control col-md-7 col-xs-12" readonly value="Meal Entertainment Card">
@Html.ValidationMessageFor(m => m.MealEntertainmentCard, "", new { @class = "text-danger" })
</div>
</div>
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
@Html.CheckBoxFor(m => m.LivingExpensesCard, new { @class = "input-text chkb" })
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
<input type="text" id="living-expense-card" class="form-control col-md-7 col-xs-12" readonly value="Living Expense Card">
@Html.ValidationMessageFor(m => m.LivingExpensesCard, "", new { @class = "text-danger" })
</div>
</div>