Asp.Net MVC를 시작하려고합니다. 이것은 내 cshtml에 : 양식은 내가 이전 값이로 유지 아직 비어하기 위해 Username
속성을 삭제하고 게시 할 때 당신이 볼 수 있듯이모델 값이 지워지지 않는 이유는 무엇입니까?
public class HomeController : Controller
{
public ActionResult Index()
{
ViewBag.Message = "Modify this template to jump-start your ASP.NET MVC application.";
return View();
}
[HttpPost]
public ActionResult Index(TestModel testModel)
{
ViewBag.Message = "Modify this template to jump-start your ASP.NET MVC application.";
testModel.Username = string.Empty;
return View(testModel);
}
}
:
@using (Html.BeginForm("Index", "Home", FormMethod.Post, new { @class = "form-horizontal" }))
{
@Html.TextBoxFor(m => m.Username, new { @class = "form-control" })
<input type="submit" value="Submit" />
}
이 내 컨트롤러입니다. 내가 뭘 놓치고 있니?
브라우저 자동 완성이 아닙니까? –
뷰에 중단 점을 넣고 모델의 값이 무엇인지 확인할 수 있습니까? – Sefa
인덱스 GET 뷰가 모델을 전달하지 않으므로 testModel.Username을 어떻게 처리해야하는지 알 수 있습니까? – markpsmith