confirmation on deletion

  • Thread starter Thread starter Imran Aziz
  • Start date Start date
I

Imran Aziz

Hello All,
I have a delete link on my page, which when clicks calls the URL for
deletion, in ASP we use to create a java script confirm box to confirm
delete, how can that be done in ASP? Say if I use an ASP link control , or
if I use a html anchor link.

This is how I am trying to do it
<script language="javascript">

function ConfirmDelete(nChannelID)

{

if (confirm("Are you sure you want to delete this source?")

{

return true;

}

else

{

return false;

}


}

</script>

<a href="viewsources.aspx?action=del&nChannelID=<%#
DataBinder.Eval(Container.DataItem, "nChannelID") %>" onclick="return
ConfirmDelete('<%# DataBinder.Eval(Container.DataItem, "nChannelID")
%>del</a>

Please suggest, thanks a lot.

Imran.
 
This may not be the answer but I think you have a syntax issue:

<a href="viewsources.aspx?action=del&nChannelID=<%#
DataBinder.Eval(Container.DataItem, "nChannelID") %>" onclick="return
ConfirmDelete('<%# DataBinder.Eval(Container.DataItem, "nChannelID")


%>')>del</a> <========HERE

Clint Hill
H3O Software
http://www.h3osoftware.com
 
Thanks, that was not the issue, that was just a sample, anyway did sort out
the issue using onclick event for the anchor link.

Imran.
 
Here's some server side code that uses javascript to display a confirmation
message.

myDeleteButton.Attributes.Add("onclick", _
"return confirm('Are you sure you want to delete?');")

In this example, the Delete button will post back only if the person
confirms they want to delete. Otherwise the server code is never called in
response to the button click.

Here's more info:
http://SteveOrr.net/articles/ClientSideSuite.aspx
 
Back
Top