Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/73.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 将文本字段设置为只读_C#_Html_Asp.net Mvc_Razor - Fatal编程技术网

C# 将文本字段设置为只读

C# 将文本字段设置为只读,c#,html,asp.net-mvc,razor,C#,Html,Asp.net Mvc,Razor,我正在使用下面的代码使文本条目成为只读,但这并没有变成只读。我不知道为什么会这样 @Html.EditorFor(model => model.UserName, new { Readonly = "Readonly"}) 试试textboxfor @Html.TextBoxFor(model => model.UserName, new { @readonly = true}) 你为什么继续使用 @Html.EditorFor(model => model.UserNam

我正在使用下面的代码使文本条目成为只读,但这并没有变成只读。我不知道为什么会这样

@Html.EditorFor(model => model.UserName, new { Readonly = "Readonly"})
试试textboxfor

@Html.TextBoxFor(model => model.UserName, new { @readonly = true})
你为什么继续使用

@Html.EditorFor(model => model.UserName, new { @readonly = true});
或者你可以用like

@Html.EditorFor(model => model.UserName, new { @readonly = "readonly"});

HtmlHelper
EditorFor
没有采用HTML属性的重载

使用
TextBoxFor

@Html.TextBoxFor(model=>model.UserName,新的{disabled=“disabled”,@readonly=“readonly”})


希望它有帮助

请参见编辑现在我已经看到不是“只读”而是“只读”这不起作用,因为等号之前的只读不会被重新确认