I have a bunch of very similar pages on my site, and on many of them, I have ImageButtons that remove or delete some sort of grid/tree entry. For all of those, I want to tie a javascript that essentially pops up a "Do you really want to delete x" dialog window.
It's working fine on almost every page, but on this particular one, the script never fires. When inspecting the button, I see the onclick event corretly listed. But upon clicking the button, I get the following console error on the client:
ReferenceError: removeButtonConfirmation is not defined
And nothing else happens.
The button in the .ascx file:
<telerik:GridTemplateColumn UniqueName="DeleteColumn">
<ItemTemplate>
<asp:ImageButton runat="server" ID="DeleteButton" CommandName="Delete" />
</ItemTemplate>
</telerik:GridTemplateColumn>
The code behind:
var deleteButton = item["DeleteColumn"].FindControl("DeleteButton") as ImageButton;
deleteButton.ImageUrl = UrlHelper.SharedImage("delete2.png");
deleteButton.ToolTip = SiteTextResources.Administration_ShippingManager_Remove;
var onclickValue = String.Format("return removeButtonConfirmation('{0}');", "Are you sure you want to delete this?");
deleteButton.Attributes.Add("onclick", onclickValue);
The js:
function removeButtonConfirmation(message) {
var result = window.confirm(message);
if (result)
return true;
else
return false;
}