This is a migrated thread and some comments may be shown as answers.

GridEditCommandColumn confirm box? Possible?

2 Answers 148 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mike
Top achievements
Rank 1
Mike asked on 10 Feb 2012, 07:47 PM
I would like to add a confirm dialog box to a GridEditCommandColumn on an ImageButton. Is this possible? I do not see any properties that suggest it is. Please advise.

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 13 Feb 2012, 05:29 AM
Hello,

Try the following code snippet.
C#:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
 if (e.Item is GridDataItem)
 {
   GridDataItem item = (GridDataItem)e.Item;
   ImageButton img = (ImageButton)item["EditCommandColumn"].Controls[0];
   img.Attributes.Add("OnClick", "confirmBox()");
 }
}

JS:
function confirmBox()
 {
     confirm("Are u sure");
 }

-Shinu.
0
Mike
Top achievements
Rank 1
answered on 13 Feb 2012, 09:57 PM
Thank you for the reply. While your suggestion did infact give me a confirm box the delete operation was not correctly cancelling out on cancel or x-out.

Doing more research I found the following: http://www.telerik.com/help/aspnet-ajax/grid-adding-delete-prompt.html

Adding the "OnClientClick" event to my code behind worked successfully. 

Thanks again for the reply. 
Tags
Grid
Asked by
Mike
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Mike
Top achievements
Rank 1
Share this question
or