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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T16:15:39+00:00 2026-06-10T16:15:39+00:00

I am using asp.net mvc 3 and have strongly typed models to pass to.

  • 0

I am using asp.net mvc 3 and have strongly typed models to pass to. The models will accept data if it is in a proper form. This form dictates that the data be in NameMatchingModel=value separated by &. For example, if I had:

viewmodel:

public class CarViewModel
{
 public Car Car { get; set; }
}

public class Car
{
 public string Make { get; set; }
 public string Model { get; set; }
}

and then I had a method accepting this ViewModel

public ActionResult AcceptCarVM( CarViewModel model )
{
 //TODO: use car data
 return View();
}

Now, I want to pass in the viewmodel filled with some details for the car. Is there a better approach to doing this than this manual way?

var carMake = "Ford";
var carModel = "Pinto";
var viewModelData = "Car.Make=" + carMake + "&Car.Model=" + carModel;
var encodeData = encodeURIComponent(viewModelData);
$.ajax({
            url: "@(Url.Action("AcceptCarVM"))",
            type: 'GET',
            data: encodeData,
            success: function (result) {
                //TODO: use result
        }
});
  • 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-10T16:15:40+00:00Added an answer on June 10, 2026 at 4:15 pm

    jQuery has a function to serialize query strings

    $.param
    

    Here’s the documentation

    You will of course provide your data in a different manner… But since you’re nesting types I could suggest to use the .toDictionary plugin that will correctly serialize JSON objects regardless of their structure, and also convert dates in a way that Asp.net MVC will understand when data binding.

    var data = {
        Car: {
            Make: "Ford",
            Model: "Pinto"
        }
    };
    
    $.ajax({
        url: "@(Url.Action("AcceptCarVM"))",
        type: 'GET',
        data: $.toDictionary(data),
        success: function(result) {
            // TODO: use result
        }
    });
    

    or even:

    var data = {
        Make: "Ford",
        Model: "Pinto"
    };
    
    $.ajax({
        url: "@(Url.Action("AcceptCarVM"))",
        type: 'GET',
        data: $.toDictionary(data, "Car"), // will provide root object's name
        success: function(result) {
            // TODO: use result
        }
    });
    

    The second one is especially useful when you have a controller action that takes two parameters of the same type, so you can provide root object’s name the same as action parameter names, so they’ll get correctly data bound on the server side ie:

    public ActionResult AcceptCarVM(CarViewModel carOne, CarViewModel carTwo) { ... }
    

    Plugin internally uses jQuery functionality so it serializes things reliably and is especially suited for Asp.net MVC back-end.

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

Sidebar

Related Questions

I wrote an application using ASP.NET MVC, in this application I have an Index
I am using ASP.NET MVC 1.0. I have an ActionResult which receives a form
I am using asp.net mvc 2.0(default binding model) and I have this problem. I
I have a asp.net mvc view which is strongly typed view and i have
With ASP.NET MVC 1.0 I always have been able to generate strongly typed links
Using Asp.net MVC, I have one view that's strongly bind to List , and
I am using asp.net MVC to develop an application that will have ajax interactions.
I'm using ASP.NET MVC and have a model which has an image (byte array)
I'm using ASP.NET MVC 2 and have a login page that is secured via
Using ASP.Net MVC on my Site.Master I have: <head runat=server> <title><asp:ContentPlaceHolder ID=TitleContent runat=server />

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.