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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T04:07:44+00:00 2026-05-31T04:07:44+00:00

I have data posted with my <input type=submit value =submit> which has the following

  • 0

I have data posted with my <input type="submit" value ="submit"> which has the following format (checked with firebug)

Role1 true
Role1 false
Role1 true
Role1 false
Name1 "Name 1"
Name2 "Name2"

and in my controller

[HttpPost]
public ActionResult GetPostData(ArrayList data)

the issue is what kind of parameters should i put in the controller to be able to have some kind of data structure which gets filled up with the values sent by post? I don’t want to use FormCollection. I can make some sort of a PostModel, but all these data is sent through hidden fields dynamically generated with jquery in most of the time so I cannot imagine how I can bind the postmodel with the fields.

  • 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-31T04:07:45+00:00Added an answer on May 31, 2026 at 4:07 am

    I guess you meant (as having Role1 four times seems a bit weird):

    Role1 true
    Role1 false
    Role2 true
    Role2 false
    Name1 "Name 1"
    Name2 "Name2"
    

    You could use a view model:

    public class MyViewModel
    {
        public bool Role1 { get; set; }
        public bool Role2 { get; set; }
        public string Name1 { get; set; }
        public string Name2 { get; set; }
    }
    

    and then:

    [HttpPost]
    public ActionResult GetPostData(MyViewModel model)
    {
        ...
    }
    

    And since I suspect you are doing checkboxes stuff (due to the double boolean value for each role as the CheckBox helper generates a hidden field), here’s what I will suggest you:

    Model:

    public class RoleViewModel
    {
        public bool IsSelected { get; set; }
        public string Name { get; set; }
    }
    
    public class EditRolesViewModel
    {
        public RoleViewModel[] Roles { get; set; }
    }
    

    Controller:

    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            var model = new EditRolesViewModel
            {
                Roles = new[]
                {
                    new RoleViewModel { Name = "Role 1", IsSelected = true },
                    new RoleViewModel { Name = "Role 2", IsSelected = false },
                    new RoleViewModel { Name = "Role 3", IsSelected = true },
                }
            };
            return View(model);
        }
    
        [HttpPost]
        public ActionResult Index(EditRolesViewModel model)
        {
            return View(model);
        }
    }
    

    View:

    @model EditRolesViewModel
    
    @using (Html.BeginForm())
    {
        for (int i = 0; i < Model.Roles.Length; i++)
        {
            <div>
                @Html.HiddenFor(x => x.Roles[i].Name)
                @Html.LabelFor(x => x.Roles[i].IsSelected, Model.Roles[i].Name)
                @Html.CheckBoxFor(x => x.Roles[i].IsSelected)
            </div>
        }
        <button type="submit">OK</button>
    }
    

    or even better, using an editor template which will be rendered for each role:

    @model EditRolesViewModel
    
    @using (Html.BeginForm())
    {
        @Html.EditorFor(x => x.Roles)
        <button type="submit">OK</button>
    }
    

    and the editor template (~/Views/Shared/EditorTemplates/RoleViewModel.cshtml):

    @model RoleViewModel
    
    <div>
        @Html.HiddenFor(x => x.Name)
        @Html.LabelFor(x => x.IsSelected, Model.Name)
        @Html.CheckBoxFor(x => x.IsSelected)
    </div>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code: <form action= method=get onsubmit=doRequest($('word').value); $('word').value=''; return false;> <input type=text
I have various PHP files which data is Posted to (like the password when
I have the following scenario: I have a content type called 'Product' in which
I have a problem. I have 2 php scripts, one which sends xml data
I have a form (posted below) and the value submitted for the checkbox does
I have ExtJS post data from a combofield to CodeIgniter. CodeIgniter reads the posted
I have an Activity that is successfully invoked for the MIME type in which
I have a form which posts data to the same page. Based on the
I have data in a MySQL database. I am sending the user a URL
I have data coming from the database in the form of a DataSet .

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.