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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T16:45:55+00:00 2026-05-30T16:45:55+00:00

I have a checkbox, but the form is being submitted the value ticked are

  • 0

I have a checkbox, but the form is being submitted the value ticked are not being submited…

Html:

@foreach (var radiobutton in Model.InterestedIn)
           {
             <span >  @Html.CheckBox("selected", radiobutton)
               <label>@radiobutton</label></span>
               <br />
           } 

Model:

[Display(Name = "Would you be interested in receiving *")]
        public IList<string> InterestedIn { get; set; }

Controller:

IList<string> lists = new List<string>();
            lists.Insert(0, "Latest News");
            lists.Insert(1, "Special Offers");
            lists.Insert(1, "New Products");
            model.InterestedIn = lists;

PostMethod:

[HttpPost]
        public ActionResult Index(Competition model)
        {
            if (ModelState.IsValid)
            {
  • 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-30T16:45:56+00:00Added an answer on May 30, 2026 at 4:45 pm

    I don’t that your code will compile at all. The CheckBox helper expects a boolean as second argument whereas you are passing it a string.

    Try like this:

    @model MyViewModel
    
    @using (Html.BeginForm())
    {
        foreach (var value in Model.InterestedIn)
        {
            <span>
                <input type="checkbox" name="interestedin" value="@Html.AttributeEncode(value)" />
                <label>@value</label>
            </span>
            <br />
        } 
        <button type="submit">OK</button>
    }
    

    This assumes that you have the following view model:

    public class MyViewModel
    {
        [Display(Name = "Would you be interested in receiving *")]
        public IList<string> InterestedIn { get; set; }
    }
    

    and the following controller:

    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            IList<string> lists = new List<string>();
            lists.Insert(0, "Latest News");
            lists.Insert(1, "Special Offers");
            lists.Insert(1, "New Products");
            var model = new MyViewModel();
            model.InterestedIn = lists;
            return View(model);
        }
    
        [HttpPost]
        public ActionResult Index(MyViewModel model)
        {
            return View(model);
        }
    }
    

    If you want to use the CheckBox or even better the CheckBoxFor helper you will have to adapt your view model so that it no longer has an IList<string> property but an IList<CheckBoxItemViewModel> property where CheckBoxItemViewModel is another view model that will contain the label and a boolean property indicating whether this value has been selected or not.

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

Sidebar

Related Questions

In my application I have methods which returns a control (checkbox, radiobutton, textbox) but
I have Jquery Form plugin but i do not have submit button in my
I have datagridview with checkbox column, but I want, that some of the columns
i have one problem controlling checkbox, i'm reading, and searching about the topic but
I have added checkbox selection model to grid panel. It works fine in IE8
I have a checkbox that when it is clicked it submits the form to
I have a checkbox who's checked value is bound to a binding source which
I have a checkbox with id terms and a submit button in my form
I have my checkbox for a bool field like so in my view: =Html.CheckBox(Active,
I have table rows of data in html being filled from a CGI application.

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.