Questions tagged [checkboxfor]

84 questions
82
votes
7 answers

Proper usage of .net MVC Html.CheckBoxFor

All I want to know is the proper syntax for the Html.CheckBoxFor HTML helper in ASP.NET MVC. What I'm trying to accomplish is for the check-box to be initially checked with an ID value so I can reference it in the Controller to see if it's still…
sagesky36
  • 4,542
  • 19
  • 82
  • 130
18
votes
1 answer

ASP.net MVC CheckBoxFor casting error

I have a EF entity that is tied to a SQL table that contains a bit field called "Active". I generate the Edit code from the T4 template, and the page inherits from the EF entity. At the bottom of the page, it generated a CheckBoxFor like this: <%=…
Jeremy Sullivan
  • 995
  • 1
  • 14
  • 25
18
votes
2 answers

MVC3 - Viewmodel with list of complex types

Apologies if this has been asked before; there are a million ways to phrase it so searching for an answer has proved difficult. I have a viewmodel with the following properties: public class AssignSoftwareLicenseViewModel { public int LicenseId…
InsqThew
  • 587
  • 2
  • 6
  • 10
11
votes
4 answers

Setting html attribute that is reserved keyword in Html.CheckBoxFor in ASP.NET MVC

I am using the HtmlHelper to create a checkbox in my view like so: <%= Html.CheckBoxFor(model => model.SeatOnly, new { checked = "checked" })%> However, an error is being thrown as checked is a reserved keyword. I have found a couple of people…
jcvandan
  • 14,124
  • 18
  • 66
  • 103
10
votes
4 answers

Asp .net mvc 3 CheckBoxFor method outputs hidden field, that hidden field value is false when checkbox is disabled with selected true

CheckBoxFor(t => t.boolValue, new { disabled="disabled" }) method to render a checkbox, in disabled mode. The method renders a hidden field as well. My question is why does this hidden field has a false value for disabled check box? I believe the…
Shameet
  • 113
  • 1
  • 1
  • 8
6
votes
2 answers

razor editorfor checkbox event binding

I cant bind event to @html.editorfor I've heard it might be connected to presence of "class" attribute but I can see no connection whatsoever. @Html.EditorFor(model => model.SameAsBaseAddress, new { @onclick = "checkboxcheck()" }) function…
Michael Brennt
  • 731
  • 9
  • 20
5
votes
2 answers

How do I bind to a List as a Property on a Model in MVC 3 Razor?

I've got a model that looks something like this: public class EditUserViewModel { public EditUserViewModel() { } public EditUserDataModel User { get; set; } } With a backing object that looks like…
Joe
  • 669
  • 1
  • 8
  • 21
4
votes
3 answers

ASP.net MVC Checkbox Issue

I am working on an ASP.net MVC project and I am using the CheckBoxFor helper method to provide the value for a boolean in my model like so: @Html.CheckBoxFor(m => m.ShouldSaveSearch, new { id="ShouldSaveSearch"}) If the checkbox gets checked by the…
bjonnn
  • 43
  • 1
  • 6
3
votes
1 answer

how to place a kendo check box label on the left

I have the following peace of code: @(Html.Kendo().CheckBoxFor(m => m.IsActive).Label("Active:")) I would like the label to be on the left as opposed to the right. Can someone help me please?
Fred K.
  • 33
  • 1
  • 4
3
votes
1 answer

Save changes on CheckBox change?

I have an MVC Index page that reflects a table in the DB. One of the columns is a boolean. I want to have a checkbox right in the index page, that when clicked, immediately calls an action that will save the new status on the spot without having to…
Shimmy Weitzhandler
  • 101,809
  • 122
  • 424
  • 632
2
votes
4 answers

How to have ASP.Net MVC 3.0 Checkboxfor as checked by default?

I want mt view to have the check box checked by default, I tried something like this. @Html.CheckBoxFor(model=>model.GenericsOK, new { id = ViewBag.GenericsOK, @checked = true }) and also @Html.CheckBoxFor(model=>model.GenericsOK, new { id =…
HaBo
  • 13,999
  • 36
  • 114
  • 206
2
votes
0 answers

Checkbox in sweet alert is not getting clicked

I am using sweetalert in MVC project, and rendering checkbox in to sweetalert using CheckBoxFor html helper. But when I clicked on these checkboxes, sometime it is getting clicked and sometime it is not getting clicked. I am not getting the reason…
Dreamer
  • 586
  • 3
  • 7
  • 23
2
votes
0 answers

How to bind Dictionary to CheckBoxFor?

I am wondering if it is somehow possible to bind the value of a Dictionary to a CheckBoxFor? I tried to do it like this: View @for (int c = 0; c < Model.ObjectsWithPermission[a].PermissionColumns.Count; c++) { …
David Walser
  • 183
  • 20
2
votes
1 answer

CheckBoxFor not correctly registering when checked

Pretty classical use of checkbox for if it where not for the case that I write in a dictionnary. When starting the website I go to the page with the checkboxes. Here, my dictionnary exists and is populated with values set to false : Before the quiz,…
Lymn
  • 65
  • 10
2
votes
2 answers

ASP.Net MVC List of Checkboxes

I am passing a model to a view, which containt a List of items. A DefaultCategories has an id (int), a description (string), and a selected boolean property. I need to list these items, with a checkbox, and check the ones where the selected property…
Craig
  • 18,074
  • 38
  • 147
  • 248
1
2 3 4 5 6