나는 무슨 일이 일어나고 있는지 극단적으로 혼동합니다. 그래서 Go는 부울 변수이고 내 모델 이동에서 현재 true가됩니다. 어떻게이 두 가지 결과가 다른 값을 갖습니까?ASP.NET MVC3 | Model.Go가 true 임에도 불구하고 CheckBoxFor (m => m.Go)가 선택되어 있지 않습니다.
@Html.TextBoxFor(m => m.Go);
@Model.Go;
@Html.CheckBoxFor(m => m.Go);
나 체크 박스를 예상하고있어 체크되지 않은 박스 (FALSE로
@ Html.CheckBoxFor (m => m.Go) 결과로
@ Html.TextBoxFor (m => m.Go) 결과)
@ Model.Go 결과를 TRUE로 설정하십시오. (예상 되나요)
어떻게 @ Html.TextBoxFor (m => m.Go)가 false가됩니까?
및
어떻게 @ Html.CheckBoxFor (m => m.Go)가 UNCHECKED 상자가됩니다. 대단히 감사합니다!
내 CONTROLLER 것보다는 아마
[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);
}
네,이 MvcHtmlString http://msdn.microsoft.com/en-us/library/system.web.mvc.mvchtmlstring.aspx – asawyer
반환 : 당신이 시도하면 어떻게됩니까 그것은 bool 값을 반환하지 않는다는 것을 이해합니다. 나는 그것을 테스트하기 위해 텍스트 상자를 사용하고있었습니다. 오히려 @ Html.CheckBoxFor (m => m.Go)라고 말하고 model.go는 true이지만 체크 박스는 확인하지 않습니다 – AustinT
Ok! 그 질문은 정확히 분명하지 않았습니다. 미안합니다. 100 % 확실한가요? 면도칼에 중단 점을 넣고 확인하십시오. – asawyer