How to stop an event firing in Client Side Scripting

J

Jorge Luzarraga C

Hello,

I have a Web Form which has two imagebuttons (Save and Cancel). I´d like to
show the user a confirm dialog whenever he clicks on the Cancel Button and
based on his answer to this confirmation continue with the postback or
cancel the action.

How could I do that?

Whenever the user clicks on the cancel buttton I get the dialog but no
matter what answer the user gives I still get a postback.


btnCancelar.Attributes.Add("onclick","event.cancelBubble = !confirm('¿Desea
Cancelar la Edición de la Prima?');");





TIA,



Jorge Luzarraga
 
B

bruce barker

btnCancelar.Attributes.Add("onclick","return !confirm('¿Desea Cancelar la
Edición de la Prima?');");


-- bruce (sqlwork.com)
 
E

Eliyahu Goldin

Jorge,

If you don't want a postback, why are you using imagebutton webcontrol? Use
html <img ..> instead.

Eliyahu
 
J

Jorge Luzarraga C

Thanks for the Help, Bruce.

Actually the solution you proposed was one.

btnCancelar.Attributes.Add("onclick","return confirm('¿Desea Cancelar la
Edición de la Prima?');");

I also learned (after digging a while in the msdn.com website) that I could
inherit the ImageButton to get the behaviour I was looking for so I would
get a ConfirmImageButton.

I´ve attached the link to that article which seems interesting.

http://msdn.microsoft.com/library/d...-us/dnaspp/html/aspnet-injectclientsidesc.asp
 
J

Jorge Luzarraga C

Because I wanted a deterministic postback depending on the confirm dialog.
Anyway I got the solution. Thanks for your help anyway.
 

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
474,434
Messages
2,571,685
Members
48,796
Latest member
Greg L.

Latest Threads

Top