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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:21:56+00:00 2026-05-25T02:21:56+00:00

Is there a way to structure the html of a form to post all

  • 0

Is there a way to structure the html of a form to post all data for the Item class? Here are the classes and controller action:

public class Item
{
    public Item (){}

    public string Name { get; set; }
    public string Description { get; set; }
    public List<string> Tag { get; set; }
    public List<Note> Notes {get; set; }
}

public class Note
{
    public string Id { get; set; }
    public string NoteText { get; set; }
    public string OtherStuff { get; set; }
}

[HttpPost]
public ActionResult SaveItemcontroller(Item SubmittedItem)
{
    DataLayer.Save(SubmittedItem);
}

When I post the following my action method gets an object with Name, Description, and a list of tags:

$.ajax({ type: "POST", dataType: "json", url: $(form).attr('action'), data: $(form).serialize()});

<form method="post" action="/saveitemcontroller">
    <input id="Name" name="Name" type="text">
    <input id="Description" name="Description" type="text">
    <input name="Tag" type="text">
    <input name="Tag" type="text">
    <input name="Tag" type="text">
    <input name="Tag" type="text">
</form>

My question, is there a way to structure the html to include Note objects within the POSTed Item object? Or is the only way to play around with the javascript data object after it gets serialized?

SOLUTION

    <input name="Notes[0].Id" type="text">
    <input name="Notes[0].NoteText" type="text">
    <input name="Notes[0].OtherStuff" type="text">


    <input name="Notes[1].Id" type="text">
    <input name="Notes[1].NoteText" type="text">
    <input name="Notes[1].OtherStuff" type="text">


    <input name="Notes[2].Id" type="text">
    <input name="Notes[2].NoteText" type="text">
    <input name="Notes[2].OtherStuff" type="text">


</form>

NOTE: when javascript is used to add or delete new groupings, it need to make sure the sequence starts at zero and increases +1 without skipping any numbers. An alternative to keeping track of the index numeric sequence is to create a hidden index element that links each grouping together:

    <input name="Notes[**anythingstring**].Id" type="text">
    <input name="Notes[**anythingstring**].NoteText" type="text">
    <input name="Notes[**anythingstring**].OtherStuff" type="text">
    <input name="Notes.Index" type="hidden" value="**anythingstring**">
  • 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-25T02:21:57+00:00Added an answer on May 25, 2026 at 2:21 am

    If you use

    Html.EditorFor(o=>o.Notes) 
    

    these items I believe should be rendered with the proper IDS on them that the model binder will pick up properly as long as you just serialize the form then.

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

Sidebar

Related Questions

Is there any way to get a map or other data structure of the
Is there any tricky way to implement a set data structure (a collection of
If for example I have the following HTML structure <ul class=actions> <li class=action>Action 1</li>
Is there a better way to structure this, using html and php? If I
So i have this structure html <span class=label data=data/support_icon.png> <span class=title>1 User/Location - 8Am
the html structure: <div id=test> <form> <input type=radio name=content class=s_code checked=checked /><span>code</span> <input type=radio
given the html structure: <div class=image-container> <img id=firstslide src=img/verybig.jpg> </div> I wonder if there
Is there a clever way to structure my WCF service, such that I can
Is there a simple way to serialize a single-level structure as a string for
I was wondering if there is a way to print just the structure of

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.