I have an ImageButton with an onclientclick js function attached:
deleteButton = new ImageButton();
deleteButton.ID = "deleteRiskButton" + planRisk.Id;
deleteButton.ImageUrl = "../../Images/deleteButton.gif";
deleteButton.Click += new ImageClickEventHandler(deleteButton_Click);
deleteButton.OnClientClick = "removeRowAfterDeletion('" + deleteButton.ID + "')";
Inside this JavaScript function i have a dialog making sure the user intended to delete the item in question.
function removeRowAfterDeletion(buttonId)
{
var deleteConfirmationDialog = confirm("Are you sure you want to remove this risk from your plan?.")
return deleteConfirmationDialog;
}
I was under the impression that if the onclientclick function returns false then the postback would not occur. However, even if the I click cancel the deleteButton_Click c# function is called.
Any idea what the problem is?