我对正在发生的事情感到非常困惑。所以 Go 是一个布尔变量,在我的模型中 Go 当前结果为真。为什么这两个会导致不同的值?
@Html.TextBoxFor(m => m.Go);
@Model.Go;
@Html.CheckBoxFor(m => m.Go);
@Html.TextBoxFor(m => m.Go) 结果为 FALSE
@Html.CheckBoxFor(m => m.Go) 结果为 UNCHECKED 框(当我预期为选中框时)
@Model.Go 结果为 TRUE(我期望发生的事情)
@Html.TextBoxFor(m => m.Go) 怎么会是假的?
以及
为什么 @Html.CheckBoxFor(m => m.Go) 会导致一个 UNCHECKED 框。非常感谢!
我的控制器
[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<string> list = new List<string>();
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);
}