根据调用的视图更改文本框的状态

change the state of a textbox depending on which view is called

我是 MVC 的新手,想知道在 C# mvc5 中,如果我想将文本框的状态从启用更改为禁用,反之亦然,我需要使用哪种代码哪个视图正在调用局部视图。

尝试在您的标签中添加如下内容:@('Condition Here') ? disabled:"disabled" : ""

或者:

object mode = ('Condition Here') ? null : new {disabled = "disabled" };
   @Html.TextBoxFor(x => x.YourPropertyHere, mode)