Multiple radio button groups in MVC 4 Razor

后端 未结 5 1697
耶瑟儿~
耶瑟儿~ 2020-12-03 06:33

I need to have multiple radio button groups in my form like this:
\"enter

I know

5条回答
  •  误落风尘
    2020-12-03 07:18

    I was able to use the name attribute that you described in your example for the loop I am working on and it worked, perhaps because I created unique ids? I'm still considering whether I should switch to an editor template instead as mentioned in the links in another answer.

        @Html.RadioButtonFor(modelItem => item.Answers.AnswerYesNo, "true", new {Name = item.Description.QuestionId, id = string.Format("CBY{0}", item.Description.QuestionId), onclick = "setDescriptionVisibility(this)" }) Yes
    
        @Html.RadioButtonFor(modelItem => item.Answers.AnswerYesNo, "false", new { Name = item.Description.QuestionId, id = string.Format("CBN{0}", item.Description.QuestionId), onclick = "setDescriptionVisibility(this)" } ) No
    

提交回复
热议问题