confirmation on deletion

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.
 
C

Clint Hill

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
 
I

Imran Aziz

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.
 
S

Steve C. Orr [MVP, MCSD]

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,819
Latest member
masterdaster

Latest Threads

Top