Click here to Skip to main content
15,905,508 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
btn_delete.Attributes.Add("onclick", "return confirm('Do you want to Delete This Record');");
but when i click on cancel in confirmation box then btn_delete client enevr fire it should not be . how it is done
Posted
Comments
uspatel 25-Apr-12 6:21am    
where you add btn_delete.Attributes.Add("onclick", "return confirm('Do you want to Delete This Record');");
Nilesh Patil Kolhapur 25-Apr-12 7:19am    
write above code at pageload

Solution 1 is in correct direction. To keep it simple:
C#
btn_delete.Attributes.Add("onclick", "if(!confirm('Are you sure that you want to delete this comment?')) return false;");
 
Share this answer
 
Comments
ajithk444 10-Aug-12 2:25am    
this works fine. i need to set some caption for this pop up.how can i do it?
kesav prakash 10-Jul-13 7:33am    
in which event we have to write the delete coding
Use OnclientClick event of button
return confirm('Are you sure you want to delete this Role?');"
 
Share this answer
 
Comments
ajithk444 10-Aug-12 2:25am    
this works fine. i need to set some caption for this pop up.how can i do it?
you can also add OnClientClick="return confirm('Are you certain you want to delete this User?')" in <asp:button ...." />
 
Share this answer
 
v2
Comments
ajithk444 10-Aug-12 2:25am    
this works fine. i need to set some caption for this pop up.how can i do it?
You can use like this,

C#
btn_delete.Attributes.Add("onclick", "if(confirm('Are you sure that you want to delete this comment?')){return true;} else {return false;};");
 
Share this answer
 
v2
Comments
Sandeep Mewara 25-Apr-12 11:27am    
My 5 for answer in correct direction and someone down-voted it!
ajithk444 10-Aug-12 2:25am    
this works fine. i need to set some caption for this pop up.how can i do it?

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