HTML.TextBoxFor能不能只读取不修改

@Html.TextBoxFor(model => model.Name, new { @readonly="readonly"})

//切记后面匿名对象不要直接写readonly="readonly",因为readonly是关键字,一定加上“@”符号。

@Html.TextBoxFor(model => model.Name, new { disabled = "disabled " })
@Html.TextBoxFor(model => model.Name, new { disabled = "" })

另外EditorFor不能设置只读,需要改成TextBoxFor才行

猜你喜欢

转载自blog.csdn.net/qq_33380252/article/details/85708523