Skip to content Skip to sidebar Skip to footer

Asp.net Mvc3 | Checkboxfor(m => M.go) Is Unchecked, Even Though My Model.go Is True

I am extremely confused with what is going on. So Go is a boolean variable and in my Model Go is currently resulting to true. How come these two result in a different value? @Html.

Solution 1:

More than likely, you have something in ViewBag or ViewData called Go, and it's interfering with things. MVC prefers model state over model values when rendering.

Solution 2:

I believe that for a boolean value, you should probably consider using a checkbox instead of a text box. What happens if you try:

@Html.EditorFor(m=>m.Go)

Post a Comment for "Asp.net Mvc3 | Checkboxfor(m => M.go) Is Unchecked, Even Though My Model.go Is True"