Note that there are some explanatory texts on larger screens.

plurals
  1. POASP.NET MVC3 | CheckBoxFor(m => m.Go) is unchecked, even though my Model.Go is true
    primarykey
    data
    text
    <p>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?</p> <pre><code>@Html.TextBoxFor(m =&gt; m.Go); @Model.Go; @Html.CheckBoxFor(m =&gt; m.Go); </code></pre> <p>@Html.TextBoxFor(m => m.Go) Results to FALSE<br> @Html.CheckBoxFor(m => m.Go) Results to an UNCHECKED box (when i'm expected a checked box)<br> @Model.Go Results to TRUE (What I expect to happen)</p> <p>How come @Html.TextBoxFor(m => m.Go) is resulting to false?<br> and<br> How come @Html.CheckBoxFor(m => m.Go) is resulting an UNCHECKED box. Thank you very much!</p> <p>My CONTROLLER </p> <pre><code> [HttpPost] public ActionResult IXT_FS_LeakCheckAnode(IXT_FS_LeakCheckAnodeModel model, string buttontype) { model.FormObject = new FormSubmitObject(); // If the Go has been hit, set the FormObject go be true also. if (model.Go) { model.FormObject.go = true; } // Add values if necessary, If its not on a submit it will be okay, because it will not submit in the model. List&lt;string&gt; list = new List&lt;string&gt;(); list.Add("SNT" + model.MainSerial); list.Add("USR" + model.BadgeID); list.Add("TMS" + 0); model.FormObject.MainSerial = model.MainSerial; // Sets the main serial model.FormObject = mm.submitGetFormHelper(model.FormObject, "XFA", list, ModelState.IsValid, buttontype); if (model.FormObject.checkmsg == "go_pass") // Update header info. { model.TubeType = model.FormObject.form_values_dict["TUT"]; model.FormObject.go = true; model.Go = true; } else if (model.FormObject.checkmsg == "get_pass") // Update the empty filled. { model.BadgeID = model.FormObject.form_values_dict["USR"]; model.MainSerial = model.FormObject.form_values_dict["SNT"]; // Grabs the TMS double value and converts it into a Time Stamp. double latestDate_dbl = Convert.ToDouble(model.FormObject.form_values_dict["TMS"]); DateTime latestDate = mm.parseTimeStamp(latestDate_dbl); model.LatestDate = "Completed on: " + latestDate.ToString(); ViewData["Error"] = model.FormObject.errormsg; } else if (model.FormObject.checkmsg == "submit_pass" || model.FormObject.checkmsg == "clear_pass")// Clear form and let operator submission passed. or clear button { ModelState.Clear(); IXT_FS_LeakCheckAnodeModel clear_model = new IXT_FS_LeakCheckAnodeModel(); return View(clear_model); } ViewData["Error"] = model.FormObject.errormsg; return View(model); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload