Disabled button with a alert is clickable in IE8 (browser compatibility Issue in Asp.net website)

与世无争的帅哥 提交于 2019-12-02 18:51:52

问题


I have disabled a link button and image button(which is inside a link button so that I can show a Alert) and it works fine in Chrome, but when I open it in IE8 the image is disabled but when i click it it shows the popup('Are you sure you want to delete this User?'). Why am I getting this error in IE8 and IE7, how can I fix this.

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

Code from view source:

 <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>

回答1:


Why not merge the ImageButtons purpose with the LinkButton? (or vice versa...)

<asp:LinkButton runat="server" ID="lBtnDeleteUser" OnClick="lBtnDeleteUser_Click"
OnClientClick='return confirm("Are you sure you want to delete this User?")'
style="display: block; background-image: url('Styles/Images/icon_delete.png');
width: widthOficon_delete.pngInPixels; height: heightOficon_delete.pngInPixels;"
ToolTip="Delete" />



回答2:


<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"/>

I solved it by using pop up in Image button [Learnt a new thing that HTML does not have a disabled attribute for links]



来源:https://stackoverflow.com/questions/8521688/disabled-button-with-a-alert-is-clickable-in-ie8-browser-compatibility-issue-in

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!