View Engine:Razor
@model MyData
@Html.TextBoxFor(model => model .myfield)
或
Html.TextBoxFor 預設值設定:
@Html.TextBoxFor(m => m.StudName, new { @Value = "預設值"})
註:@Value 的V 一定要大寫
後端處理完畢的回傳值指定方式:
@Html.TextBoxFor(m => m.StudName, new { @Value = @ViewData["retValue"] })
或
@Html.TextBoxFor(m => m.StudName, new { @Value = @ViewBag.retValue})
請於Controller 指定 @ViewData["retValue"] 或 @ViewBag.retValue
至於如果要設定CSS的Class 請點我
全站熱搜