Hi,
I tried to implement this code in view page with model, but error occured in mvc4 c#
@model List
@{
ViewBag.Title = "_EditClientContact";
Layout = null;
}
$('input[class="chkProductDetails"]').each(function (e) {
//alert(this.id)
var chkid = 'cb_' + this.id;
@foreach(var item in Model)
{
if (chkid==item.ProductDetailsId) {
var chkclass = $(this).id;
chkclass.prop('checked', true);
}
}
});
From this code i want to check if 'chkid' is equal to 'item.ProductDetailsId' then checked true checkbox. checkbox design is given below:-
@model List
@{
ViewBag.Title = "_EditClientContact";
Layout = null;
}
$('input[class="chkProductDetails"]').each(function (e) {
//alert(this.id)
var chkid = 'cb_' + this.id;
@foreach(var item in Model)
{
if (chkid==item.ProductDetailsId) {
var chkclass = $(this).id;
chkclass.prop('checked', true);
}
}
});
From this code i want to check if 'chkid' is equal to 'item.ProductDetailsId' then checked true checkbox. checkbox design is given below:-


Jignesh KumarRank #91 · 22.9K reputationPosted Feb 20, 2020, 4:53 AM EST
Navaneeth KrishnanRank #1,172 · 1.5K reputationPosted Feb 20, 2020, 2:26 AM EST