Confirming a Deletion

M

MRW

Hello!

I'm trying to execute a code so when a record in a DetailsView is
deleted, it will first have to be confirmed (with as little code as
possible). The DetailsView is attacked to an ObjectDataSource. I was
thinking of having the ItemDeleting command 'intercept' the delete
command and make a confirmation button visible on the screen, THEN when
the person clicks the button the ObjectDataSource executes the delete
command. My question is, is there a way, in the ItemDeleting command
to stop the deletion command from executing?

Thanks for any help!
 
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
 
M

MRW

Mmm... I'll have to take a look at it. Thanks!

My original idea was to place my DetailsView in one set of div tags,
and my confirmation line (with record information) in another. When
the delete button is pressed, I wanted the first div tag to become
invisible and the second one to become visible.

Oh well...
 

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

Forum statistics

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

Latest Threads

Top