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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T12:07:53+00:00 2026-05-20T12:07:53+00:00

I have a complex form It allows the user to create an IncomeDeclaration which

  • 0

I have a complex form

It allows the user to create an IncomeDeclaration which has many Activities.

This works fine when the markup for the Activities is like this:

 <tr>
            <td>SomeActivity
                <input type="hidden" value="13123" name="EconomicActivityIncomeDeclarations[0].EconomicActivityId" id="EconomicActivityIncomeDeclarations_0__EconomicActivityId">
            </td>
             <td>
                <input type="text" name="EconomicActivityIncomeDeclarations[0].GrossIncome" id="EconomicActivityIncomeDeclarations_0__GrossIncome" />
            </td>
   </tr>

<tr>
            <td>SomeActivity
                <input type="hidden" value="654654" name="EconomicActivityIncomeDeclarations[1].EconomicActivityId" id="EconomicActivityIncomeDeclarations_1__EconomicActivityId">
            </td>
             <td>
                <input type="text" name="EconomicActivityIncomeDeclarations[1].GrossIncome" id="EconomicActivityIncomeDeclarations_1__GrossIncome" />
            </td>
   </tr>

The problem is I am dynamically adding more activities through javascript.. which is rendering the newly created form elements like this

<tr>
            <td>SomeActivity
                <input type="hidden" value="987987" name="EconomicActivityIncomeDeclarations[1b117bc9-ce4b-46d5-9de0-77ba98b82fd0].EconomicActivityId" id="EconomicActivityIncomeDeclarations_1b117bc9-ce4b-46d5-9de0-77ba98b82fd0__EconomicActivityId">
            </td>
             <td>
                <input type="text" name="EconomicActivityIncomeDeclarations[1b117bc9-ce4b-46d5-9de0-77ba98b82fd0].GrossIncome" id="EconomicActivityIncomeDeclarations_1b117bc9-ce4b-46d5-9de0-77ba98b82fd0__GrossIncome" />
            </td>
   </tr>

The weird behavior I get is that when the first two (or more) have the regular format [0], 1… and so on and then I (through ajax) add more form elements the Post Action actually only binds the ajax elements to the Model…

So basically an IncomeDeclaration which has all 3 of the activities Im using here as example will only get the THIRD one (with the random characters) added to the IncomeDeclaration….

I know its a little complicated but if anyone knows why this behavior is happening I appreciate it…

btw, heres what Im using.
http://blog.stevensanderson.com/2010/01/28/editing-a-variable-length-list-aspnet-mvc-2-style/

  • 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-20T12:07:54+00:00Added an answer on May 20, 2026 at 12:07 pm

    You may want to look at this post: http://haacked.com/archive/2008/10/23/model-binding-to-a-list.aspx in the end Haacked talks about a helper he made to bind items when they aren’t a sequence.

    That said I usually take another route when I have a complex list. It will only work with javascript enabled though. On submit I build a json object representing the list. Then I use the json2 library to stringify the json and place it in a hidden field which get’s posted. On the serverside it’s easy to build the list by using the JavaScriptSerializer and it’s Deserialize method.

    This is a bit more work though. I would guess it ends up at about 8 rows of javascript and 2 rows of serverside code.

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

Sidebar

Related Questions

I have a complex django object, which has properties of other class types. This
I have a complex form to allow the user to configure my app. What's
I have complex form that I want to make more user friendly. It consists
I have built a fairly complex form which includes a hidden section that the
I have created a form, quite complex, with user input unique values, integers and
I have some complex stored procedures that may return many thousands of rows, and
I have a complex WPF UserControl made of other ContentControl templates which contain sets
I have been working on quite a complex accordion/form recently and have a select
I have a login.jsp page which contains a login form. Once logged in the
I have a complex form for scheduling events. Here are the abbreviated associations: class

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.