samedi 29 avril 2017

Razor Mvc Only one checkbox selected

I am using MVC 5,razor,C# and in the view i have 4 checkboxes for each question and must select only 1 checkbox for each question. I must use Javascript to be able to do this and how I can do it?

 for (var i = 0; i < Model.Count; i++)
    {
        @Html.DisplayFor(model => model[i].QuestionTx)
        @Html.HiddenFor(model => model[i].Id)
        @Html.HiddenFor(model => model[i].ClassTestId)
        @Html.HiddenFor(model => model[i].QueastionMarksInt)
        <br />
        <br />
        for (var o = 0; o < Model[i].ClassTestQuestionMc.Count; o++)
        {
          @Html.DisplayFor(model => Model[i].ClassTestQuestionMc[o].AnswerTx)
            @Html.CheckBoxFor(model => Model[i].ClassTestQuestionMc[o].IsChecked) 
              @Html.HiddenFor(model => Model[i].ClassTestQuestionMc[o].AnswerTx)
            @Html.HiddenFor(model => Model[i].ClassTestQuestionMc[o].IsChecked)
            @Html.HiddenFor(model => Model[i].ClassTestQuestionMc[o].Id)
            @Html.HiddenFor(model => Model[i].ClassTestQuestionMc[o].IsCorrectAnswer)

        }
        <br />
        <br />
        <br />
    }




Aucun commentaire:

Enregistrer un commentaire