繁体   English   中英

如何使ImageButton无法点击

[英]How to make ImageButton not clickable

我在转发器中有许多ImageButton,根据每个记录,这些图像中的一些将是可点击的,而其他的,我已禁用该按钮以停止回发。

我现在已经改变了每个图像的不透明度,所以除非你在那个图像按钮上盘旋,否则它将是0.6。 麻烦的是,对于那些我已经禁用的人,显然我不能改变悬停的不透明度。

目前我这样做:

    if (vessel.IsRegistered)
    {
        imagebuttonRegistration.ImageUrl = ("../Images/Icons/registrationApproved.gif");
        imagebuttonRegistration.CommandArgument = null;
        DisableImageButton(imagebuttonRegistration);                
        imagebuttonRegistration.ToolTip = GetLocalResourceObject("imageButRegistrationRegisteredText").ToString();
    }

public static void DisableImageButton(ImageButton imagebutton)
{
    imagebutton.Attributes.Remove("href");
    imagebutton.Attributes.Add("disabled","disabled");            
}

但是,由于禁用按钮现在导致我出现问题,我怎么可能只是停止按钮可点击/没有回发但允许使用其他属性。

尝试这个:

imagebutton.Attributes.Add("onclick","return false");
imagebutton.Style.Add("cursor","context-menu");

使用Css的不同方式:

在你的css文件中添加:

.notclickable{
    cursor:text;    
}

并在DisableImageButton方法中添加:

imagebutton.Attributes["class"] ="notclickable";

你可以使用CSS

.imagebutton:disabled {
不透明度:0.7;
}

看一下这个:

http://www.w3schools.com/cssref/sel_disabled.asp

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM