Razor - TextBoxForにデフォルト値を設定する

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


トップ   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS