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 請點我
arrow
arrow
    全站熱搜

    湯瑪的吳 發表在 痞客邦 留言(0) 人氣()