更新时间:2023-12-06 13:25:04
您可以在MVC控件中使用disabled属性,如下所示:
@ Html.TextBoxFor(m => m.ModelPropertyName,new {disabled =disabled})
如果你想让它只读,那就用下面的代码
@ Html.TextBoxFor(m => m.ModelPropertyName, new {@readonly =readonly})
you can use the disabled property in the MVC Control like below:
@Html.TextBoxFor(m => m.ModelPropertyName,new{disabled="disabled"})
If you want to make it readonly then use below code
@Html.TextBoxFor(m => m.ModelPropertyName, new { @readonly = "readonly" })
您好,
请参阅下面的CodeProject文章。
使用MVC Razor视图引擎和扩展方法启用/禁用网页上的控件 [ ^ ]
谢谢
Hi,
Please refer CodeProject article below.
Enable/Disable controls on a web page using MVC Razor view engine and Extension methods [^]
Thanks
CodeProject [ ^ ]
google上的第一个答案。下次再不是盲目地问。谢谢。
CodeProject[^]
First answer on google. Next time to that instead of asking blindly. Thank you.