使文本字段可查看但不可编辑(making text field viewable but not editable)
我使用下面的代码允许用户添加视图的用户名,因为这个名称由活动目录给出我希望他们看到添加了名称的文件但不能编辑数据任何想法我将如何能够实现这一点
@Html.EditorFor(model => model.UserName)我也尝试了以下两种方法,这些方法与@ anslo一起使用,并且与statment都无效
@Html.EditorFor(model => model.UserName, new { @disabled ="disabled"}) @Html.EditorFor(model => model.UserName, new { @readonly = "readonly" })I am using the code bellow to allow users to add view the user name as this name is given by the active directory i would like them to see the filed with name added but not able to edit the data any ideas how i would be able to achieve this
@Html.EditorFor(model => model.UserName)I have also tried the folowwing two methods which do no work both with or with @ anslo with the statment true
@Html.EditorFor(model => model.UserName, new { @disabled ="disabled"}) @Html.EditorFor(model => model.UserName, new { @readonly = "readonly" })最满意答案
去找@Html。 您可以传递重载的TextBoxFor扩展:
@Html.TextBoxFor(model => model.UserName, new { @readonly = true })Go for go @Html.TextBoxFor extension which you can pass an overload:
@Html.TextBoxFor(model => model.UserName, new { @readonly = true })更多推荐
发布评论