[英]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;
}
看一下這個:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.