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('Are you sure you want to delete this User?');"
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't have permission to delete users" class="aspNetDisabled"
src="Styles/Images/icon_delete.png" alt="Delete User" src=""
style="border-style: none" /></a>
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 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" />
Method 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]
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0