MVC3如何禁用/启用的ActionLink [英] MVC3 How to disable/enable ActionLink
本文介绍了MVC3如何禁用/启用的ActionLink的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我如果有状况,我想禁用或启用我的ActionLink的按钮。
I have if condition and I want to disable or enable my actionLink button.
我会怎么做呢?
@ Html.ActionLink(删除,删除,新{ID = @ Model.Id})
谢谢,
推荐答案
如果您知道在服务器端该链接不可用,只是呈现一个消息,该操作是不可用:
If you know on the server side that the link is not available then just render a message that the action is not available:
@if(condition)
{
@Html.ActionLink("Delete", "Delete", new { id = @Model.Id})
}
else
{
<text>Action is not available</text>
}
否则,你只能禁用的链接
Otherwise you can only disable a link with
- CSS:使用CSS 禁用链接
- JS:<一href=\"http://stackoverflow.com/questions/1164635/how-to-enable-or-disable-an-anchor-using-jquery\">How启用或使用jQuery禁用锚?
- CSS: Disable a link using css
- JS: How to enable or disable an anchor using jQuery?
要使它工作跨浏览器:<一href=\"http://stackoverflow.com/questions/7000927/should-the-html-anchor-tag-honor-the-disabled-attribute\">Should在HTML锚标记荣誉残疾人属性?
To make it work cross-browser: Should the HTML Anchor Tag Honor the Disabled Attribute?
这篇关于MVC3如何禁用/启用的ActionLink的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文