2011-12-15 53 views
0

可能重複:
Disabled button with a alert is clickable in IE8 (browser compatibility Issue in Asp.net website)如何改變支持C#disabled屬性爲true

enter image description here

<asp:LinkButton ID="lnk_DeleteUser" ToolTip="Delete User" runat="server" OnClientClick="return confirm('Are you sure you want to delete this User?')"> 
            <asp:ImageButton ID="Img_del" src="Styles/Images/icon_delete.png" OnClick="imgbtn_UserDeleteClick" 
             runat="server" Style="border-style: none" alt="Delete User" /></asp:LinkButton> 

我想禁用鏈接按鈕和圖像按鈕某些條件,但我不能禁用鏈接按鈕,因爲當調試ng我發現支持禁用屬性是false。因爲在IE8中的圖像是禁用的,但鏈接按鈕沒有被禁用,我能夠得到確認彈出窗口。

這是從瀏覽器

<a onclick="return confirm(&#39;Are you sure you want to delete this User?&#39;);" id="ctl00_MainContent_UserTable_ctl02_lnk_DeleteUser" title="Delete User" class="aspNetDisabled"><input type="image" name="ctl00$MainContent$UserTable$ctl02 $Img_del" id="ctl00_MainContent_UserTable_ctl02_Img_del" disabled="disabled" title="You don&#39;t have permission to delete users" class="aspNetDisabled" src="Styles/Images/icon_delete.png" alt="Delete User" src="" style="border-style: none" /></a> 

回答

2

這種控制不支持禁用屬性的源代碼。
你不能神奇地告訴它支持這個屬性。

特別是,HTML鏈接沒有disabled屬性。

+0

使用服務器端`if`設置屬性。 – SLaks 2011-12-15 15:43:01

0
<asp:ImageButton ID="Img_del" runat="server" Text="Delete" ImageUrl="Styles/Images/icon_delete.png" 
           AlternateText="Delete" OnClientClick='return confirm("Are you sure you want to delete this item?");' OnClick="imgbtn_UserDeleteClick"/> 

我解決它在圖像按鈕使用彈出[記者獲悉,HTML沒有的鏈接禁用屬性的新事物]

相關問題