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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:55:40+00:00 2026-06-17T20:55:40+00:00

Hihi, Having trouble model binding with this class (the following concrete, not the abstract).

  • 0

Hihi,

Having trouble model binding with this class (the following concrete, not the abstract).
Ignore the basic properties, its the Lists that I’m interested in binding.

public abstract class MessageModel
{
    public string Tag { get; set; }
    public string Message { get; set; }
    public int Id { get; set; }
    public const int DefaultIdValue = Int32.MinValue;

    public List<LinkModel> Linked { get; set; }
    public List<LinkModel> NotLinked { get; set; }

    protected MessageModel()
    {
        Id = DefaultIdValue;
        Linked = new List<LinkModel>();
        NotLinked = new List<LinkModel>();
    }

    protected MessageModel(string tag, string message):this()
    {
        Tag = tag;
        Message = message;
    }
}

public class TextModel:MessageModel
{
        public int TextId { get; set; }

        public TextModel()
        {
                TextId = DefaultIdValue;
        }
}

This is the submission I get on the server side on submit (formatted for sanity):

Tag=
&Message=
&NotLinked.index=35fda83a053645e6809bbb8b0ea00103
&NotLinked.index=14c2e286e28b4c9d8f889fb3eb437e5f
&NotLinked.%5b35fda83a053645e6809bbb8b0ea00103%5d.RecipientId=1
&NotLinked.%5b35fda83a053645e6809bbb8b0ea00103%5d.RecipientName=Bob+Biggins
&NotLinked.%5b14c2e286e28b4c9d8f889fb3eb437e5f%5d.RecipientId=2
&NotLinked.%5b14c2e286e28b4c9d8f889fb3eb437e5f%5d.RecipientName=Billy+Oswold
&Submit=Submit

When the function is called that accepts that model the NotLinked collection is set to null. D:

The (relevant) output html looks like this (im trying to “faux” bind to:

<ol> and <li> 

with jQuery doing the work of moving stuff around)

<div id="NotLinkedContainer">
    <ol id="NotLinked" name="NotLinked" style="width: 500px;height: 200px">
        <li value="1">Bob Biggins
            <input id="NotLinked_index" name="NotLinked.index" type="hidden" value="a0ab331bee2a461084b686e13a87090b" />
            <input id="NotLinked__a0ab331bee2a461084b686e13a87090b__RecipientId" name="NotLinked.[a0ab331bee2a461084b686e13a87090b].RecipientId" type="hidden" value="1" />
            <input id="NotLinked__a0ab331bee2a461084b686e13a87090b__RecipientName" name="NotLinked.[a0ab331bee2a461084b686e13a87090b].RecipientName" type="hidden" value="Bob Biggins" />
        </li>
        <li value="2">Billy Oswold
            <input id="NotLinked_index" name="NotLinked.index" type="hidden" value="d7d294d3174c4bd98d583e92010359e7" />
            <input id="NotLinked__d7d294d3174c4bd98d583e92010359e7__RecipientId" name="NotLinked.[d7d294d3174c4bd98d583e92010359e7].RecipientId" type="hidden" value="2" />
            <input id="NotLinked__d7d294d3174c4bd98d583e92010359e7__RecipientName" name="NotLinked.[d7d294d3174c4bd98d583e92010359e7].RecipientName" type="hidden" value="Billy Oswold" />
        </li>
    </ol>
</div>

Any ideas? Haven’t done this sort of complex binding before so I’m at a loss at the simple mistake I’ve probably made.

  • 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-17T20:55:42+00:00Added an answer on June 17, 2026 at 8:55 pm

    Try removing the dot notation before the brackets and since this isn’t a dictionary, but a list, you need to use indices, not keys. The correct syntax for a list in a razor view should look more like this:

    <div id="NotLinkedContainer">
        <ol id="NotLinked" name="NotLinked" style="width: 500px;height: 200px">
            <li value="1">Bob Biggins
                <input id="NotLinked_index" name="NotLinked.index" type="hidden" value="a0ab331bee2a461084b686e13a87090b" />
                <input id="NotLinked__a0ab331bee2a461084b686e13a87090b__RecipientId" name="NotLinked[0].RecipientId" type="hidden" value="1" />
                <input id="NotLinked__a0ab331bee2a461084b686e13a87090b__RecipientName" name="NotLinked[0].RecipientName" type="hidden" value="Bob Biggins" />
            </li>
            <li value="2">Billy Oswold
                <input id="NotLinked_index" name="NotLinked.index" type="hidden" value="d7d294d3174c4bd98d583e92010359e7" />
                <input id="NotLinked__d7d294d3174c4bd98d583e92010359e7__RecipientId" name="NotLinked[1].RecipientId" type="hidden" value="2" />
                <input id="NotLinked__d7d294d3174c4bd98d583e92010359e7__RecipientName" name="NotLinked[1].RecipientName" type="hidden" value="Billy Oswold" />
            </li>
        </ol>
    </div>
    

    Here is an article that covers what you are attempting to do:

    http://haacked.com/archive/2008/10/23/model-binding-to-a-list.aspx

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

Sidebar

Related Questions

So I'm having a problem doing an assignment for my java class. The purpose
I am wondering why $(this) does not work after a jQuery ajax call. My
<html> <head> <style> .100PercentHeight{ } </style> </style> <body> <div class='100PercentHeight'>hihi</div> </body> </html> How can
I try to delete some datas, and this is the model of my Tables
Hihi all, This could very well be a silly question. I would like to
I have been having problems with this on both netbeans and eclipse even with
This is what I'm trying: public partial class _Default : System.Web.UI.Page { String test
Can anybody tell me how are exceptions handled in PHP? I have this code
I keep getting a compilier error whenever I run this... I am quite sure
I have the following HTML: <html> <head> <title> Think in a NEW BOX. </title>

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.