OnClientClick='<%# "return confirm(\"do you want to delete " + Eval("Name") + "\")" %>'>
Visual basic
OnClientClick='<%# "return confirm(""do you want to delete " + Eval("Name") + """)" %>'>
using the onclientclick event of the button, linkbutton, or imagebutton control, we can add the confirm javascript function.
for each double quote closing or opening a string, we need to add the escape character \. The Eval function takes as a parameter whichever field name we need to display in the confirm section.
this technique has been around since .net 1.0, implemented in different ways. the onclientclick event is new in .net 2.0 and up, which makes it useful in this situation.
Comments are welcome
7 comments:
Many thanks
I wasted half a day trying to figure this out, that is using a confirm delete message with record info.
you're a genius! - JL
Glad I could help. I have always searched for a simple and clear solution to the confirm delete technique (since .net 1.x). this works :) thanks
THANK YOU!!!!! that's what i was looking for...
Glad this helps. Beleive it or not, I come back often to this post, during my develpopment, and do copy and paste :)
too bad, we cannot create code snippets for asp.net code
Good luck everyone!
Thank You Buddy!
Nice Trick, I was find for long time that.
Good idea
Post a Comment