I have a partial view like bellow
@model IEnumerable<elearnerhub.Common.Entities.ViewModel.elearnerhub.vm_eLearning_Master_QuestionSet_AnswerOptions>
@foreach (var item in Model)
{
<div class="form-group">
@Html.LabelFor(m => item.AnswerShownOrder,item.AnswerShownOrder.ToString(), new { @class = "control-label col-md-3 col-sm-3 col-xs-12" })
<div class="col-md-4 col-sm-4 col-xs-4">
@Html.TextBoxFor(m => item.AnswerOptionText, new { @class = "form-control", @id=item.PK_MasterQuestion_AnswerOptionID, Name = "AnswerOptionText" })
</div>
<div class="col-md-2 col-sm-2 col-xs-2">
@Html.CheckBoxFor(m => item.CorrectAnswer, new { @class = "form-control", @id = "chk"+item.PK_MasterQuestion_AnswerOptionID, @Name = "CorrectAnswer" })
</div>
</div>
}
public PartialViewResult _QuestionAnswerOptions(Int64 noofoptions)
{
List<vm_eLearning_Master_QuestionSet_AnswerOptions> _vm_eLearning_Master_QuestionSet_AnswerOptions = new List<vm_eLearning_Master_QuestionSet_AnswerOptions>();
for(int i = 0; i <= noofoptions-1; i++)
{
var obj = new vm_eLearning_Master_QuestionSet_AnswerOptions
{
PK_MasterQuestion_AnswerOptionID= i + 1,
AnswerShownOrder=i+1,
AnswerOptionText="",
CorrectAnswer=false
};
_vm_eLearning_Master_QuestionSet_AnswerOptions.Add(obj);
}
return PartialView("_QuestionSet_AnswerOptions");
}
and the hidden field generate with checkbox with different name .please see the screen shot of inspect element
How to set the name of the hidden field same as check box?