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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:06:35+00:00 2026-05-27T18:06:35+00:00

I have a third party control that utilizes a single hidden input field to

  • 0

I have a third party control that utilizes a single hidden input field to store a list of integers. This control is used throughout the site on numerous forms.

The submitted value (as displayed in Fiddler) is:

items=1,35,346,547

The controller action looks like:

public ActionResults SomeAction(IEnumerable<int> items) {...}

As expected, the DefaultModelBinder fails to parse the list of integers. Given that I do have the ability to change the format of the input value, is there a format that would enable the default model binder to parse this for me?

I could easily change the action to have a string parameter and handle the parsing myself, however I’d like the model binder to do this for me. I could also intercept the form submit and scrape/change the data/data-type to JSON (or someother format), however I’d really like to avoid this approach. Another option would be to create a custom model binder, but this seems like it might be a bit of overkill.

Recommendations?

  • 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-27T18:06:35+00:00Added an answer on May 27, 2026 at 6:06 pm

    Description

    No the Default Model Binder can’t do this. You can create a custom Model Binder that handle that. Asuming your input field name is items my sample should work, if not change it to the right name.

    Sample

    public class MyCustomModelBinder : IModelBinder
    {
        public object BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext)
        {
            List<int> result = new List<int>();
    
            var value = bindingContext.ValueProvider.GetValue("items").AttemptedValue;
    
            foreach (string i in value.Split(",".ToCharArray()))
            {
                int a;
                if (Int32.TryParse(i, out a))
                    result.Add(a);
            }
            
            return result;
        }
    }
    
    public ActionResult SomeAction([ModelBinder(typeof(MyCustomModelBinder))] List<int> list)
    

    More Information

    • Custom Model Binders in MVC 3 with IModelBinder
    • ASP.NET MVC Custom Model Binding
    • DefaultModelBinder Sourcecode

    Update

    You can register your Custom Model Binder in global.asax

      ModelBinders.Binders.Add(typeof(List<int>), new MyCustomModelBinder());
    

    but be aware that this would always try to bind if you have List<int> in your Action Method.

    According to your comment: There is no way, at the moment, that makes it possible to say the Default Model Binder to do that because he try to bind the properties and don’t know when you want to bind List<int>and when not.

    You can see the source of the DefaultModelBinder here

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

Sidebar

Related Questions

Currently I have a third party control that generates a Metafile. I can save
We have a Windows Forms application that uses a (third party) ActiveX control, and
I have an MFC application that uses an ancient (circa 1999) third-party ActiveX control.
I have a third party control that I assume gets a style from somewhere.
I have an ASP Page that uses two listboxes and a third party control
So I have this SDK provided by a third party which is used for
I have a third party library that internally constructs and uses the SqlConnection class.
I have a third-party app that creates HTML-based reports that I need to display.
I have an third-party applet that requires JRE v1.5_12 to work correctly. THe user
I have a third-party product, a terminal emulator, which provides a DLL that can

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.