2014-12-02 96 views
1

我有一箇中繼器內的ImageButtons數量,取決於每個記錄這​​些圖像中的一些可點擊和其他人,我已禁用該按鈕來停止回發。如何使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");    
} 

但作爲禁用按鈕現在導致我的問題,我怎麼可能只是停止按鈕爲可點擊/無回傳,但允許使用的其他屬性。

+1

可能替代將是'imagebutton.Attributes.Add( 「點擊」, 「返回false」); ' – 2014-12-02 11:26:41

+0

是的,但它似乎仍然是一個可點擊的鏈接,這可能會導致混淆。我的意思是光標仍然會變成懸停狀態。 – JsonStatham 2014-12-02 11:30:13

+1

@SelectDistinct,你可以通過使用Css將光標更改爲指針? – Max 2014-12-02 11:38:30

回答

1

不同的方式使用CSS:

在你的CSS文件中加入:

.notclickable{ 
    cursor:text;  
} 

而且在DisableImageButton方法Add:

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

試試這個:

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