如何完全禁用链接按钮? [英] How to completely disable the link button?

查看:130
本文介绍了如何完全禁用链接按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可能重复:结果
  <一href=\"http://stackoverflow.com/questions/754497/disabling-linkbutton-doesnt-disable-the-click-event-in-javascript\">Disabling LinkBut​​ton的并不在JavaScript中禁用click事件

我在ASP.NET一个LinkBut​​ton。

I have a linkbutton in ASP.NET.

我已经设置其属性启用= FALSE;

I have set its property Enabled = false;

<asp:LinkButton ID="lnkButton" runat="server" 
                Enabled = "false" 
                OnClientClick="return confirm('Are you sure ?')" > Click Me
                        </asp:LinkButton>

事件还以为我已经设置了属性启用=假的OnClientClick 事件仍然被解雇了。

我如何prevent烧制而成的的OnClientClick 事件?

How can I prevent the OnClientClick event from firing?

推荐答案

这是从<一个href=\"http://weblogs.asp.net/akjoshi/archive/2009/10/03/disabling-linkbutton-hyperlink-and-imagebutton-completely.aspx\">Disables链接按钮

/// <summary>
/// Disables the link button.
/// </summary>
/// <param name="linkButton">The LinkButton to be disabled.</param>
public static void DisableLinkButton(LinkButton linkButton)
{
    linkButton.Attributes.Remove("href");
    linkButton.Attributes.CssStyle[HtmlTextWriterStyle.Color] = "gray";
    linkButton.Attributes.CssStyle[HtmlTextWriterStyle.Cursor] = "default";
    if (linkButton.Enabled != false)
    {
       linkButton.Enabled = false;
    }

    if (linkButton.OnClientClick != null)
    {
        linkButton.OnClientClick = null;
    }
}

检查这也是<一个href=\"http://www.aspnetajaxtutorials.com/2009/05/how-to-enable-or-disable-linkbutton-in.html\">how-to-enable-or-disable-linkbutton

这篇关于如何完全禁用链接按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆