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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T23:28:51+00:00 2026-05-30T23:28:51+00:00

I have the following form: <li> <% using (Html.BeginForm(TestMethod, MyController, FormMethod.Post, new {id =

  • 0

I have the following form:

 <li>
                                    <% using (Html.BeginForm("TestMethod", "MyController", FormMethod.Post, new {id = "TestMethod"}))
                                       {%>
                                           <%= Html.Hidden("model", Model.MyListOfObjects) %>

                                     <%}%>
                                      <a href="#" onclick="SubmitForm()">Test</a>
                                   </li>

And the javascript function for the onclick is as follows:

   function SubmitForm() {
  document.forms["TestMethod"].submit();
 }

I am trying to pass the list of objects from the view into the controller, but i have yet managed to get this to work. My Controller function is:

 [Authorize]
    [HttpPost]
    public ActionResult TestMethod(List<Objects> model)
    {
        dynamic Expando = new ExpandoObject();
        Expando.test = model; 
        return View(Expando );
    }

When I view the List of objects in the debugger it always displays “System.Collections.Generic.List`1[]” with no actual objects inside.

So my question is what should I be doing to pass a List of objects into a controller?

I have also tried:

 <% using (Html.BeginForm("TestMethod", "MyWork", FormMethod.Post, new {id = "TestMethod"}))
                                       {%>
                                       <% int itemx = 0; %>
                                       <% foreach (var x in Model.MyListOfObjects)
                                          {%>
                                            <%= Html.Hidden("model"+"["+itemx+"]", x) %>
                                            <%itemx++; %>
                                          <% } %>


                                     <%}%>
  • 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-30T23:28:53+00:00Added an answer on May 30, 2026 at 11:28 pm

    You cannot just put List<object> as action parameter and expect the model binder to be able to automagically guess what object types you want to put there. You will need to write a custom model binder if you wanted to handle multiple sub-types as illustrated in this post.

    And if you want to use a single type for the list such as List<MyViewModel> then simply loop through each element of the list (respecting the convention) and for each element build a hidden field for each property that you want to bind.

    But since those are hidden fields, I guess that the user is not supposed to modify them. In this case those hidden fields have nothing to do in your view. Let’s not reinvent the ViewState that we were all so happy to get rid of when we moved to ASP.NET MVC from classic WebForms. Simply put a hidden field containing an unique id that will allow you to refetch the corresponding list elements in the POST action given this unique id from wherever you fetched them initially (your database or something I suppose).

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

Sidebar

Related Questions

I have an image upload form <% using (Html.BeginForm(PictureValidateAndSave, UserGallery, new {}, FormMethod.Post, new
I have the following code: <% using (Html.BeginForm(AddComment, Comments, FormMethod.Post)) { %> <div id=New_Comment>
I have following code @using (Html.BeginForm()) { @Html.DropDownListFor(m => m.IDs, new SelectList(Model. IDs), Model.SelectedID)
i'm using the following post type: <% using (Html.BeginForm()) { %> <%= Html.Hidden(EligiblePages, Model.EligiblePages)
In my html I have <h2>Title goes here</h2> @using (Html.BeginForm(Action, Controller, FormMethod.Post, new {
I have the following form in a partial view @model PartDetail @using (Ajax.BeginForm(Create, Part,
Suppose I have the following within a webpage <% using (Html.BeginForm(ShowData, Summary)) %> <%
I have a the following code @using (Ajax.BeginForm(new AjaxOptions { UpdateTargetId = update_panel, Url
Something strange is happening here. I have a basic form: <% using (Html.BeginForm()) {
I have in my Form constructor, after the InitializeComponent the following code: using (WebClient

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.