-1

Having tried what feels like everything, including the following, I can't find a way of disabling the edit icon based on a condition.

<a asp-action="Edit" asp-route-id="@item.Id" disabled="@ViewBag.status">
  <i class="fas fa-edit disabled" style="color:darkolivegreen" title="Edit Bundle" disabled="@ViewBag.status"></i>
</a>
A Cameron
  • 27
  • 7

2 Answers2

0

<a> doesn't have disable feature. We need to use pointer-events. Try code below:

<a asp-action="Edit" asp-route-id="@item.Id" style="pointer-events:@(ViewBag.status ? "none":"auto" )">
    <i class="fas fa-edit disabled" style="color:darkolivegreen;" title="Edit Bundle" >jump</i>
</a>
Tiny Wang
  • 10,423
  • 1
  • 11
  • 29
0

I wrapped two button options: one enabled and a one disabled in an if(){} and that worked, although not very elegant. Here is the code:

<div class="form-group">
  @{
    if (ViewBag.missing == 0)
    {
      <input type="submit" class="btn btn-primary" disabled="disabled" value="Select Node(s)" />
    }
    else
    {
      <input type="submit" class="btn btn-primary" value="Select Node(s)" />
    }
  }
</div>
A Cameron
  • 27
  • 7