tags:

views:

9

answers:

1

I have a survey form. The questions and options are generated from the database. There are 5 questions in the form, each are generated using the partial view.

The question is a partial view and the options are templated view.

The problem is when submitting the form and the user did not select an answer, it will show a validationsummary. The problem is the selected answers are gone.

Partial View


        <% for(var x = 0; x < Model.QuestionOptions.Count(); x++){%>
            <% var option = Model.QuestionOptions.ToList()[x]; %>   
            <li>        
                <%: Html.EditorFor(model => option, "RadioButton")%>
            </li>
        <% } %>

radio button template


        <%: Html.RadioButton("OptionId", Model.OptionId, false)%>

A: 

you can do the validation on the client side

http://weblogs.asp.net/scottgu/archive/2010/01/15/asp-net-mvc-2-model-validation.aspx

Mouadh