Home > Net >  ASP.net Core Conditional disable icon
ASP.net Core Conditional disable icon

Time:10-05

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  style="color:darkolivegreen" title="Edit Bundle" disabled="@ViewBag.status"></i>
</a>

CodePudding user response:

<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  style="color:darkolivegreen;" title="Edit Bundle" >jump</i>
</a>

CodePudding user response:

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 >
  @{
    if (ViewBag.missing == 0)
    {
      <input type="submit"  disabled="disabled" value="Select Node(s)" />
    }
    else
    {
      <input type="submit"  value="Select Node(s)" />
    }
  }
</div>

  • Related