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
Solution 1:
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
.
Solution 2:
Unfortunately, ActionLink
s cannot be disabled using the 'disabled' attribute like a button or a select box. You could write some JavaScript that could mimic disabling a hyperlink, but I would recommend changing your html to a button or something similar instead of a hyperlink if you want to disable it.
Solution 3:
You can do something like this using javascript return false
@Html.ActionLink("Add Account(s)", "CreateAccount", null, new { @class = "btn btnblack", @onclick = "javascript:return false;"})
Post a Comment for "In Html Attributes Setting Disabled = "disabled" Not Working"