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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T16:09:05+00:00 2026-06-17T16:09:05+00:00

I have the view that contains the checkbox and Submit button as shown below.

  • 0

I have the view that contains the checkbox and Submit button as shown below.

@using (Html.BeginForm())
    {
        <fieldset>
            <legend style="font-size: 100%; font-weight: normal">Delete</legend>
            <p> Are you sure you want to delete?</p>
            @foreach (string resource in resources)
            {
                if (resource != "")
                {
                    <input type="checkbox" name="Resources" title="@resource" value="@resource" checked="checked"/>@resource
                    <br />
                }
            }
            <br />

            @Html.HiddenFor(m => m.AttendeeListString)
        @Html.HiddenFor(m => m.ResourceListString)

            <span class="desc-text">
                <input type="submit" value="Yes" id="btnYes" />
            </span>
            <span class="desc-text">
                <input type="submit" value="No" id="btnNo" />
            </span>
        </fieldset>
    }

Below is the Controller code…

public ActionResult DeleteResource(RoomModel roomModel)
{
...
}

RoomModel contains some other data…

Now how can i access the checkbox value in controller?
Note : I have lot more information that need to be send to Controller when i clicked on submit button… Can anybody suggest some solution….

Answer :

I have added these two property to My model

public List<SelectListItem> Resources
{
    get;
    set;
}

public string[] **SelectedResource**
{
    get;
    set;
}

And My view check box i have updated as follows

@foreach (var item in Model.Resources)
{
<input type="checkbox" name="**SelectedResource**" title="@item.Text" value="@item.Value" checked="checked"/>@item.Text
<br /><br />
}

And in Controller …

if (roomModel.SelectedResource != null)
{
    foreach (string room in roomModel.**SelectedResource**)
    {
      resourceList.Add(room);
    }
}

Note: The name of check box and Property in the model should be same. In my case it is SelectedResource

  • 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-17T16:09:06+00:00Added an answer on June 17, 2026 at 4:09 pm

    You have a few options. The easiest would be:

    1) Parameter bind a view model with the Resources property. I recommend this way because it’s the preferred MVC paradigm, and you can just add properties for any additional fields you need to capture (and can take advantage of validation easily by just adding attributes).

    Define a new view model:

    public class MyViewModel
    {
        public MyViewModel()
        {
           Resources = new List<string>();
        }
    
        public List<string> Resources { get; set; }
    
        // add properties for any additional fields you want to display and capture
    }
    

    Create the action in your controller:

    public ActionResult Submit(MyViewModel model)
    {
          if (ModelState.IsValid)
          {
               // model.Resources will contain selected values
          }
          return View();   
    }
    

    2) Parameter bind a list of strings named resources directly in the action:

    public ActionResult Submit(List<string> resources)
    {
          // resources will contain selected values
    
          return View();   
    
    }
    

    It’s important to note that in the question, the view is creating checkboxes that will send the string value of all checked resources, not boolean values (as you might expect if you used the @Html.CheckBox helper) indicating if each item is checked or not. That’s perfectly fine, I’m just pointing out why my answer differs.

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

Sidebar

Related Questions

I have an ASP.NET MVC Partial View that contains a Html.TextBox that is configured
I currently have a product view page that contains an MVCContrib HTML Grid with
I have list view with custom row layout (list_row.xml) that contains CheckBox element: <TableLayout
I have a view that contains two @Html.DropDownListFor helpers: <div class=editor-field> @Html.DropDownListFor(model => model.Employee,
I have a custom cell that contains a button in a table view. The
Lets say I have a partial view that contains both a checkbox and a
I have a View that contains a ParentModel, which contains 2 Models. I only
I have a view that contains two NSTextFieldCell s. The size at which these
I have a view model that contains a Product class type and an IEnumerable<
I'm developing an iOS 4 application. I have a main view that contains another

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.