Reputation: 1082
I have a DropDownList:
@Html.DropDownList("name", (IEnumerable<SelectListItem>)SlotList[counter], new { id = "slotDDL_" + @item.ResourceID, tid = @item.ResourceID, @class = "slotDDL_ text white" })
and a CheckboxFor:
@Html.CheckBoxFor(modelItem => item.IsSelected, new { @class = "boxcheck_", id = @item.ResourceID })
When executing this:
$('.slotDDL_').change(function () {
var resId = $(this).attr("tid");
IsSelected = 'boxcheck_' + resId;
alert($('#' + resId).attr("checked"));
});
I get the following :
alert($(this).attr("tid"))====>505
alert(IsSelected)====> boxcheck_505
alert($('#' + resId).attr("checked"))===>undefined
Question: How can I successfully build the string of my Id ? What am I doing wrong ?
Upvotes: 0
Views: 48
Reputation: 16764
Try
@Html.CheckBoxFor(modelItem => item.IsSelected, new { @class = "boxcheck_", id = "@item.ResourceID" })
You missed "
for id
attribute
Upvotes: 1