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

  • Home
  • SEARCH
  • 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 576363
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T14:02:21+00:00 2026-05-13T14:02:21+00:00

I’m able to post a complex object to an ASP.NET MVC controller with jQuery,

  • 0

I’m able to post a complex object to an ASP.NET MVC controller with jQuery, as long as I modify the output of $.param() like this: “Column[0][Name]” -> “Column[0].Name”

However, this only works if the data is bound to an array-type property on the server (Columns1 in the example below). A collection type like IEnumerable or the EntitySet used by LINQ-to-SQL doesn’t work.

Should I simply define a write-only array-type property that sets the EntitySet property on binding, or is there a more elegant solution?

JavaScript

var columns =
[
    { Name: 'Alpha', Width: 50 },
    { Name: 'Bravo', Width: 100 },
    { Name: 'Charlie', Width: 75 }
];

var params = $.param(
{
    Name: 'MyTable',
    Columns1: columns,
    Columns2: columns,
    Columns3: columns
} );

params = params.replaceAll( '%5BName%5D=', '%2EName=' );
params = params.replaceAll( '%5BWidth%5D=', '%2EWidth=' );

$.post( $.getUrl( '/MyController/CreateTable/' ),
    params,
    function()
    {
        $.log( 'done' );
    } );

Domain classes

public class Table
{
    public string Name { get; set; }
    public Column[] Columns1 { get; set; }
    public IEnumerable<Column> Columns2 { get; set; }
    public EntitySet<Column> Columns3 { get; set; }
}

public class Column
{
    public string Name { get; set; }
    public int Width { get; set; }
}

Controller action

public ActionResult CreateTable( Table table )
{
    // table.Columns1 contains a list of three Columns, with Name and Width set properly
    // table.Columns2 and table.Columns3 both contain three Column objects, but Name and Width are null/0
}

EDIT

Replaced replace() string function with replaceAll(), as seen here.

  • 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-05-13T14:02:21+00:00Added an answer on May 13, 2026 at 2:02 pm

    Here’s an example of the fix I referred to in my question. It works, but would need to be implemented for all similar properties.

    “Generated” LINQ-to-SQL domain class

    public partial class Table
    {
        public string Name { get; set; }
        public EntitySet<Column> Columns { get; set; }
    }
    

    Partial class with jQuery-friendly array property

    public partial class Table
    {
        public Column[] ColumnsIn
        {
            get
            {
                // ASP.NET MVC requires a getter in all bound properties, but the returned value isn't used in this case
                return null;
            }
            set
            { 
                Columns = new EntitySet < Column > ();
                Columns.AddRange ( value );
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 312k
  • Answers 312k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer There's a few blog post out there on how to… May 13, 2026 at 10:38 pm
  • Editorial Team
    Editorial Team added an answer I ended up finding a nice tutorial on csv_builder that… May 13, 2026 at 10:38 pm
  • Editorial Team
    Editorial Team added an answer "postMessage" is essentially one half of a publish/subscribe model for… May 13, 2026 at 10:38 pm

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I want use html5's new tag to play a wav file (currently only supported
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I've got a string that has curly quotes in it. I'd like to replace
In order to apply a triggered animation to all ToolTip s in my app,

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.