使文本字段可查看但不可编辑(making text field viewable but not editable)

编程入门 行业动态 更新时间:2024-10-18 14:14:12
使文本字段可查看但不可编辑(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 })

更多推荐

本文发布于:2023-08-07 15:46:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1464559.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:字段   文本   编辑   making   editable

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!