It seems like the Internet Explorer issue has resurfaced, and I'm struggling to resolve it:
I have an ImageButton set up with OnCommand to delete a specific entry from my database. However, I've added a confirmation step for the user before deleting the item.
Below is the code snippet for my ImageButton:
<asp:ImageButton runat="server" ID="imgDelete" ImageUrl="~/Controls/TaskDetails/Images/delete.png" OnCommand="Tag_DeleteCommand" Visible='<%# CanDelete %>' OnClientClick="javascript:confirmDialog(this, 'Remove Tag','Are you sure you want to remove this tag?', 1); return false;" CommandArgument='<%# Eval("TagID") %>' />
And here's the ConfirmDialog function implementation:
function confirmDialog(sender, title, message, type) {
var sender = $(sender);
$("#message_dialog_inner_text").html(message);
$("#message_dialog_message_container").dialog({
modal: true,
title: title,
zIndex: 10003,
dialogClass: (type > 0) ? "message_dialog_type_" + type : "",
position: 'center',
buttons: {
"OK": function () {
$(this).dialog("close");
if (sender.hasAttr("href")) {
window.location = sender.attr('href');
} else {
sender.removeAttr("onclick");
sender.trigger("click");
}
},
"Cancel": function () { $(this).dialog("close"); }
}
});
return false;
This solution works perfectly on Chrome, Firefox, and Safari, but Internet Explorer ignores it and does the postback instead of handling the click event. I've tried changing OnClientClick to "return false;", switching from ImageButton to Button, but nothing seems to work. It might be related to the OnCommand event, but I'm not certain at the moment. Any insights or suggestions would be highly appreciated!
EDIT
To clarify, even when using OnClientClick="return false;" the command button still triggers a postback, which is unexpected behavior.
Here is the rendered markup generated by my ImageButton control:
<input type="image" name="ctl00$body$pnlContentRight$pnlCurrentTaskDetails$repTags$ctl00$tagItem$imgDelete" id="ctl00_body_pnlContentRight_pnlCurrentTaskDetails_repTags_ctl00_tagItem_imgDelete" src="Controls/TaskDetails/Images/delete.png" onclick="javascript:confirmDialog(this, 'Remove Tag','Are you sure you want to remove this tag?', 1); return false;" style="border-width:0px;">