I'm developing an ASP.NET MVC 5 app with Razor, C# and .NET Framework 4.7.
I want to make it a textbox not editable if Model.IsChinaProduct
is true.
I have this piece of code in a View:
@Html.TextBoxFor(m => m.Configurations[index].PkgRatio, new { @class = "productClass", @onkeydown = "IsValidKey(event);" @if (Model.IsChinaProduct) disabled})
I want to add the disabled
attribute if Model.IsChinaProduct
is true, but that code shows me the following error:
Error CS0746 Invalid anonymous type member declarator. Anonymous type members must be declared with a member assignment, simple name or member access.
How can I add the disabled
attribute if Model.IsChinaProduct
is true?
UPDATE:
Maybe disabled is not the right attribute.