Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 98995
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T00:18:10+00:00 2026-05-11T00:18:10+00:00

I’m building a questionnaire mvc webapp, and i cant figure out how to pass

  • 0

I’m building a questionnaire mvc webapp, and i cant figure out how to pass an unknown number of arguments to the controller from the form.

My form is something like:

<% using (Html.BeginForm())    { %> <div id='Content'>     <% foreach (var group in ViewData.Model.QuestionGroups)        { %>     <div class='Group'>         <%=group.Description %>         <% foreach (var question in group.Questions)            {%>         <div class='Question'>             <div class='QuestionTitle'>                 <%=question.Title %>             </div>                 <%=Html.Hidden('Id', question.ID) %>             <div class='QuestionText'>                 <%switch (question.TypeAsEnum)                   {                       case QuestionTypeEnum.Text:%>                 <%=Html.TextBox('somename') %>                 <% break;                       case QuestionTypeEnum.Number:%>                 <%=Html.TextBox('somename') %>                 <% break;                       case QuestionTypeEnum.PhoneNumber:%>                 <%=Html.TextBox('somename')%>                 <% break;                       case QuestionTypeEnum.Email:%>                 <%=Html.TextBox('somename')%>                 <% break;                       case QuestionTypeEnum.Date:%>                 <%=Html.TextBox('somename')%>                 <% break;                       case QuestionTypeEnum.YesNo:%>                 <%=Html.RadioButton('somename', true)%>                 <%=Html.RadioButton('somename', false)%>                 <% break;                       case QuestionTypeEnum.Alternative:%>                 <%=Html.DropDownList('somename', question.Answers)%>                 <% break;                   }%>             </div>         </div>         <% } %>     </div>     <% } %> </div> <div id='submittButton'>     <%=Html.SubmitButton()%></div> <% } %> 

Now what i need in my controller is List< ResponseAnswer >, where ResponseAnswer has the properties:

string questionID, string AnswerText, bool AnswerBool, number AnswerNumber, …

So how can i pass an unknown number of items containing questionID, AnswerType and Answer to the controller. In webforms i solved this by rendering the form with repeaters instead of foreach, and then iterating through the question repeater checking the control id, each repeater item containing a hidden questionid element and a input with id=AnswerType. But this will seriously break Separation of concern in mvc?

So is there any way of getting my controller to accept List< ResultAnswer > and somehow build this list without breaking soc, and if not, how do i pass the entire formresult back to the controller so i can do the iteration of the form data there instead of in the view.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T00:18:11+00:00Added an answer on May 11, 2026 at 12:18 am

    Garry’s answer will work (and hence, up voted). However, you can model bind directly to a list, and I think it’s a bit more elegant. There are instructions in this blog post.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have a text area in my form which accepts all possible characters from
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
We're building an app, our first using Rails 3, and we're having to build
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I know there's a lot of other questions out there that deal with this
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
Does anyone know how can I replace this 2 symbol below from the string
I have an MVC Razor view @{ ViewBag.Title = Index; var c = (char)146;

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.