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

GridEditCommandColumn Confirm

1 Answer 38 Views
Grid
This is a migrated thread and some comments may be shown as answers.
johnv
Top achievements
Rank 2
johnv asked on 15 Mar 2011, 05:07 PM
Hey community,

I am working with version 2010.3.1109.35 of the RadControls for ASP.NET AJAX. I have a requirement to make a confirmation dialog appear on a grideditcommandcolumn.

For our purposes, we are retooling the edit button to do a delete.

<telerik:GridEditCommandColumn UniqueName="EditCommandColumn" HeaderText="Add/Delete"
    HeaderStyle-Font-Bold
="true" ButtonType="PushButton" EditText="Delete"
        InsertText="Add" HeaderStyle-Width="130"/>

In my grids ItemDataBound event, I have the following:
if ((e.Item is GridEditableItem) && (!e.Item.Edit))
{
    GridEditableItem _item = (GridEditableItem)e.Item;
    ((Button)_item.FindControl("EditButton")).Attributes.Add("onclick", SR.GetString(SR.Message_DeletePopup, "configuration"));
}
 
...

For your convenience my SR class looks like this:
...
 
public static string GetString(string strString, string param1)
 {
       return string.Format(strString, param1);
 }
 
...
 
public const string Message_DeletePopup = "javascript:return confirm('Are you sure you wish to delete this {0}?');";
 
...


The popup confirm dialog is displayed, but the cursor returns from there (ie: my debugger doesn't see it) and my ItemCommand event is never triggered. It doesn't seem matter which button I push, OK and Cancel do the same thing.


Any ideas?

1 Answer, 1 is accepted

Sort by
0
johnv
Top achievements
Rank 2
answered on 15 Mar 2011, 07:33 PM
For your indulgence:

We figured out the problem. The javascript confirm dialog box in my SR class needed to be corrected:
public const string Message_DeletePopup = "javascript:if (!confirm('Are you sure you wish to delete this {0}?')) return false;";

Thanks!
Tags
Grid
Asked by
johnv
Top achievements
Rank 2
Answers by
johnv
Top achievements
Rank 2
Share this question
or