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 9088027
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T21:49:56+00:00 2026-06-16T21:49:56+00:00

Using MVC 3 I have a button that saves a mvc questionare form. The

  • 0

Using MVC 3

I have a button that saves a mvc questionare form. The form will have 50 or more questions with user answers. I decided to serailize the form instead of placing the answers in a array to send to the controller. Not sure how to read the form and grab the question Id and the answers?

Ajax Call:

$.ajax({
        url: '/Question/SaveQuestionaire',
        type: 'POST',
        cache: false,
        dataType: 'json',
        data: $("#SignupForm").serialize(), // creates an object for you

View:

@using COPSGMIS;
@model IEnumerable<COPSGMIS.Models.Quiz>

@{
    ViewBag.Title = "Questionaire";
}
<h2>Questionaire</h2>
  <input type="hidden" id="currentstep" name="currentstep" />
   @using (Html.BeginForm("Questionaire", "Question", FormMethod.Post, new { id = "SignupForm" }))
   {
       <div id="wizardtemplate">       
            @foreach (var step in Model)       
            {
              <fieldset class="wizard">
                <div class="page_Title"> @Html.DisplayFor(modelItem => step.Title)</div>               
                @foreach (var question in step.Results)
                {
                ... code removed ....
                <label for="question">@Html.DisplayFor(modelItem => question.NumberedQuestion)</label>  
                 @Html.Raw(Html.DisplayControl(question.QuestionID, question.Choices, question.AnswerValue,question.ControlType)) 
                 </div>                               
                 @Html.Partial("_Comment", question)
               <hr />
                }
              </fieldset>
            }

HTML RENDERED:

<label for="question">3. This is a sample question (2) for the questionare?</label>  
                 <div class='answer'><input type='date' id='3' name='3' value='2012-12-10' /></div> 
                 </div>                               
 ... code removed ....

 <label for="question">4. This is a sample question (3) for the questionare?</label>  
                 <div class='answer'><input type='text' id='4' name='4' value='999' /></div> 
                 </div>           

Model:

 public class Quiz
    {
        public int ReviewID { get; set; }
        public int StepID { get; set; }
        public string Title { get; set; }
        public virtual IEnumerable<Result> Results { get; set; }
    }

I need help with

[HttpPost]
        public ActionResult SaveQuestionaire(int reviewid, Serialized? form)
.... code here

*UPDATED CODE*PLEASE LOOk HERE

My Ajax CALL:

function saveQuestioniare() {
           alert('Here');
           $.ajax({
            url: '/Question/SaveQuestionaire',
            type: 'POST',
            cache: false,
            dataType: 'json',
            data: {reviewid: 8, col:$("#SignupForm").serialize()},
                error: function (jqXHR, textStatus, errorThrown) {
                    alert(errorThrown);
                },
            success: function (json) {
                alert("hERE!");
            }
        });
    }

MY Controller:

 [HttpPost]
        public ActionResult SaveQuestionaire(int? id, FormCollection col)
        {
            using (var db = new NexGenContext())
            {
                foreach (var key in col.AllKeys.Where(q => !q.Contains("Comment_")))
                {
                    var answer = col[key];
                    int questionId = Convert.ToInt32(key);
                    db.Database.ExecuteSqlCommand(
                            "EXEC SP_AddUpdateResponse @QuestionID, @Reviewer, @AnswerValue, @ReviewID",
                            new SqlParameter("@QuestionID", questionId),
                            new SqlParameter("@Reviewer", "TEST - CG"),
                            new SqlParameter("@AnswerValue", answer),
                            new SqlParameter("@ReviewID", id)
                        );
                }
            }
            return Json("save", JsonRequestBehavior.AllowGet);
        }
  • 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. Editorial Team
    Editorial Team
    2026-06-16T21:49:58+00:00Added an answer on June 16, 2026 at 9:49 pm

    have you tried

    $.ajax({
            url: '/Question/SaveQuestionaire',
            type: 'POST',
            cache: false,
            dataType: 'json',
            data: {model:$("#SignupForm").serialize()},
    

    and on the server side

    [HttpPost]
    public ActionResult SaveQuestionaire(int? reviewid, IList<Quiz> model)
    

    or the old school way of getting the posted form values in FormCollection

    [HttpPost]
     public ActionResult SaveQuestionaire(int? reviewid, FormCollection col)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using MVC 3 and I have a button that the user presses
I have a following table using MVC that shows number of items the user
Using MVC 3 I have a questionaire that has three sections. The page that
I have an ASP.NET MVC 2 form that is working perfectly, doing client side
I have an MVC form for adding a simple entity. I am using TextBoxFor(model
I have written a user control that contains a text box and a button.
Using Asp.net MVC, I have one view that's strongly bind to List , and
i am having an mvc 2 application in which i have a form that
I'm using MVC 2 and EF4. I have a view that displays my Application
I have an winforms application that was built using MVC. The controller is subscribing

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.