Confirm Delete Message

G

Greg Smith

What is the best way to present a "Confirm Delete" message to a user and get
the response back?

Any help is greatly appreciated.
 
S

Steph

Hi,

One possible way is to create a button and on the code-behind (click
event...):
YourButton.Attributes.Add("onclick", "javascript: return confirm('Are u sure
?');");

++
 
E

Eliyahu Goldin

A client-side onclick event.

This sets up the server-side OnClick event handler:
<asp:Button id=btnDelete runat=server OnClick=MyServerSideHandler ... >

And this sets up its client-side counterpart (c#):
btnDelete.Attributes["onclick"] = "return confirm('Please confirm
delete');";

If the user doesn't confirm, no server event will be fired.

Eliyahu
 
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 your server code is never called in
response to the button click.

Here's a more detailed analysis of your options, including a free control
that can handle many of the options for you.
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,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top