Razor - TextBoxForにデフォルト値を設定する方法1 Valueプロパティを設定するController public ActionResult Index()
{
//here you must set VALUE what u want,
//for example I set current date
Viewbag.ExactlyWhatYouNeed = DateTime.Now
return View();
}
View @Html.TextBoxFor(model => model.CurrentDate, new { @Value = ViewBag.ExactlyWhatYouNeed})
参考http://stackoverflow.com/questions/16625460/how-to-set-default-value-html-textboxfor 方法2 TextBoxを使う @Html.TextBox("CurrentDate", ViewBag.ExactlyWhatYouNeed)
参考http://mohit-aspnet.blogspot.jp/2012/08/mvc-set-default-value-in-htmltextboxfor.html |
|