Click here to Skip to main content
15,914,419 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
if (e.CommandName == "Del")
           {

               ScriptManager.RegisterClientScriptBlock(Page, this.GetType(), "Startup", "<script>ConfirmOnDelete();</script>", false);

               try
               {
                   foreach (GridDataItem i in dgTempList.MasterTableView.GetSelectedItems())
                   {
                       DateTime deletedOn = DateTime.Now;

                       string id = i["column"].Text;
                       Controllers.TempListController.DeleteTempList(Convert.ToInt32(id), deletedOn);
                   }
               }
               catch
               {
                   //message
               }

               dgTempList.Rebind();
           }
Posted
Comments
bbirajdar 7-Jul-12 2:59am    
Incomplete question- No code provided for 'ConfirmOnDelete' related to actual issue
bbirajdar 7-Jul-12 3:00am    
This code should be in Page_load
ScriptManager.RegisterClientScriptBlock(Page, this.GetType(), "Startup", "<script>ConfirmOnDelete();</script>", false);

C#
if (e.CommandName == "Del")
           {

               ScriptManager.RegisterClientScriptBlock(Page, this.GetType(), "Startup", "<script>return ConfirmOnDelete();</script>", false);

               try
               {
                   foreach (GridDataItem i in dgTempList.MasterTableView.GetSelectedItems())
                   {
                       DateTime deletedOn = DateTime.Now;

                       string id = i["column"].Text;
                       Controllers.TempListController.DeleteTempList(Convert.ToInt32(id), deletedOn);
                   }
               }
               catch
               {
                   //message
               }

               dgTempList.Rebind();
           }


ADDED RETURN before your javascript function, When your javascript function return false then no DELETE operation will perform any action and when it returns true then DELETE operation will perform.

Thanks
 
Share this answer
 
Comments
AshishChaudha 8-Jul-12 3:59am    
is this problem solved???
try with return keyword.

C#
ScriptManager.RegisterClientScriptBlock(Page, this.GetType(), "Startup", "<script>return ConfirmOnDelete();</script>", false);

or

OnClientClick="return confirm('Do you really want to delete')"
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900