I need to add a confirm pop up to basically a “delete” command.
I try to use a simple way, just add an "attribute" in the cells.
e.Row.Cells(4).Attributes.Add("onClick", "return confirm('Are you sure you want to delete the record?');")
but it cannot work~ (btw, I used the image ButtonType)
This time I ended up writing my own TemplateField. In add a onClientClick attribute. This will call your Javascript function and display a confirm popup to your users.
<asp:imagebutton id="btnDelete" runat="server" commandname="Delete" onclientclick="return confirmSubmit();" imageurl="~/images/i_delete.gif" text="Delete">
Here is the basic Javascript code to pop up a confirm button.
<SCRIPT LANGUAGE="JavaScript">
function confirmSubmit() {
var agree=confirm("Do you really want delete in the database?");
if (agree)
return true ;
else
return false ;
}
</SCRIPT>

0 comments:
Post a Comment