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

COmfirm box on cancel button in Edit/Insert mode

2 Answers 24 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Prachi
Top achievements
Rank 1
Prachi asked on 31 Jul 2012, 01:29 AM
HI,

I need to display confirm box (With option ok/cancel) when user clicks on Cancel button inside an edit or insert form.
We are adding edit button in the grid as following :

<

 

 

telerik:GridButtonColumn UniqueName="btnEdit" CommandName="Edit" Text="Edit" ButtonType="PushButton"

 

 

 

Visible="false">

We tried using oncommand and writing some javascript code but that is not an option.
It interferes with required field validators.

The cancel button is autogenerated and we are not writing any code for it.

Please suggest something as it is an urgent requirement.

 

2 Answers, 1 is accepted

Sort by
0
Accepted
Shinu
Top achievements
Rank 2
answered on 31 Jul 2012, 04:43 AM
Hello,

Try accessing the cancel button in ItemCreated event and show the confirm dialog as shown below.
C#:
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
{
   if (e.Item is GridEditFormItem && e.Item.IsInEditMode)
   {
      LinkButton cancelButton = (LinkButton)e.Item.FindControl("CancelButton");
      cancelButton .Attributes["onclick"] = "javascript:return radconfirm('Do you want to cancel edit?')";
   }
}

Thanks,
Shinu.
0
Prachi
Top achievements
Rank 1
answered on 31 Jul 2012, 08:12 PM
Thanks for the reply.
The above code is giving javascript error, But it helped me to figur out where can I add my code.

I have been able to call confirm box.
Thanks again for the heads up.
Tags
Grid
Asked by
Prachi
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Prachi
Top achievements
Rank 1
Share this question
or