MVC3 How to disable/enable ActionLink

前端 未结 5 1562
鱼传尺愫
鱼传尺愫 2020-12-10 03:04

I have if condition and I want to disable or enable my actionLink button.

How would I do it?

@Html.ActionLink(\"Delete\", \"Delete\", new { id = @Mode

5条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-10 03:45

    A little late to the party, but in case anyone else stumbles across this... If your project is bootstrapped, you can do this:

    @Html.ActionLink("Delete", "Delete", new { id = @Model.Id}, new { @class = "btn btn-default disabled" })
    

    or

    @{
        bool btnDisabled = // Logic here;
    }
    
    @Html.ActionLink("Delete", "Delete", new { id = @Model.Id}, new { @class = "btn btn-default " + @btnDisabled })
    

提交回复
热议问题