Search code examples
asp.net-mvchtml.actionlink

In html attributes setting disabled = "disabled" not working


@Html.ActionLink(" ", "Edit", new { id = item.UserId }, new { title = "User is not editable" , @class = "edit_btn", disabled = "disabled"})

I want to disable ActionLink by setting html attribute disabled ="disabled", but its not working. I am able to get class and title attributes but actionLink is not getting disabled.

Can anyone help.. Where I am doing wrong.


Solution

  • The disabled attribute doesn't work in anchor tags. MVC renders what you expect, disabled="disabled", but browsers just ignore it.

    You need to do something different, such as not rendering an anchor at all, but just render the text or in a span.