0

I'm just starting to use ASP.NET MVC Tag Helpers which are great, but I cant work out how to conditionally set boolean attributes like the disabled attribute.

For example I have a tag helper that looks something like this:

<input asp-for="MyProperty" disabled="disabled" />

But I only want the disabled part to be present when for example, @Model.IsDisabled is true.

How do I do this?

Matt Whetton
  • 6,616
  • 5
  • 36
  • 57
  • Model.IsDisabled (the entire model has a property signed as IsDisabled) or the specific input inside the model Model.SomeInput.IsDisabled ? – Orel Eraki Feb 16 '16 at 20:48
  • 2
    Take a look at this http://stackoverflow.com/questions/34866539/asp-net-conditionally-disable-a-tag-helper-textarea – Shyju Feb 16 '16 at 20:49
  • 1
    Thanks - that question did it - don't know how I missed it! – Matt Whetton Feb 16 '16 at 21:03

0 Answers0