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

grid postbackurl does not fire after confirm delete

2 Answers 32 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Saro
Top achievements
Rank 1
Saro asked on 14 May 2012, 02:14 PM
I have a telerik grid with lots of rows. i have a delete button:
<telerik:GridButtonColumn ButtonType="ImageButton"
FilterControlAltText="Filter column column" UniqueName="GridButtonDelete" CommandName="Delete">

I initially had code in the postbackurl and after the delete button was clicked I successfuly went to another page and did what i had to do. But I decided to add a client side confirmation
(item["GridButtonDelete"].Controls[0] as ImageButton).OnClientClick = "return confirm ('OK to Delete?');";
Once the confirmation was added the postbackurl of the delete button does not fire.
what am i doing wrong?

2 Answers, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 14 May 2012, 02:35 PM
Hello,

Please try with Below Code snippet.

var redirectUrl;
          function pageredirect(url) {
               
              redirectUrl = url;
              radconfirm('123', confirmCallbackForGap, 330, 100, null, '456', null);
              return false;
          }
 
          function confirmCallbackForGap(args) {
              if (args == true) {
                  window.location = redirectUrl;
              }
          }

<telerik:GridButtonColumn FilterControlAltText="Filter Download column" HeaderText="Download"
                       ImageUrl="~/Img/download.png" UniqueName="Download" ButtonType="ImageButton">

protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
    {
 
        
 
        if (e.Item is GridDataItem)
        {
            GridDataItem item = e.Item as GridDataItem;
            ImageButton ibtn= item["Download"].Controls[0] as ImageButton;
            string strUrl = "http://www.google.com/"; // set your here
            ibtn.Attributes.Add("onclick", "return pageredirect('" + strUrl + "');");
        }
}


OR

<telerik:GridButtonColumn FilterControlAltText="Filter Download column" HeaderText="Download"
                       ImageUrl="~/Img/download.png" UniqueName="Download" ButtonType="ImageButton"
                       ConfirmDialogType="RadWindow" ConfirmText="confirmn text" ConfirmTitle="title1">

Thanks,
Jayesh Goyani
0
Saro
Top achievements
Rank 1
answered on 14 May 2012, 02:55 PM
I received an answer from another user in stackoverflow which worked:

OnClientClick =

 

"if(!confirm('OK to Delete?'))return false;"

Tags
Grid
Asked by
Saro
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Saro
Top achievements
Rank 1
Share this question
or