Shout out to Andy Smith..

At the current place I'm working at these days we needed a quick and not so dirty solution for javascript style popup confirmation buttons. You know, the typical "Are you Sure?" message just after the user hits the big bad "Delete" button.
My mind went first to "How would I roll this out on my own?", then after about 1.5 seconds of thought I decided to see what good old Andy Smith over at MetaBuilders.com has baked up for us, and to see if he already rolled out a solution for it.
Yes! His "ConfirmedButtons" control was right on the mark.
Thanks again Andy!

7 Comments

  • Scott Galloway said

    Actually not too hard to do without Andy's control...
    Button1.Attributes.Add("OnClick",javascript: return confirm('Are you sure you want to delete this forum?');");

    Pretty much does the job too...

  • Andy Smith said

    Scott, Yes, ConfirmedButtons was originally created because of a bug in v1.0 of the framework. The validation framework didn't combine your onclick with it's own onclick, as it does in v1.1, but instead created two onclick attributes on the button, which meant one of them didn't fire. I created ConfirmedButtons to combine the two onclicks together at the clientside.

    Which also brings up a bug in your implementation. You only want to return false if the user chooses no. otherwise the validation doesn't fire, as it gets combined to be after any user onclick stuff. So you want to change it to Attributes.Add("onclick", "if ( !window.confirm( 'sure?' ) ) { return false; }" )

  • Fabrice said

    Hi Robert, maybe you should remove the previous comment from "John". This person is just creating links to his/here site from everywhere. I had the same comment on my weblog.

  • William said

    Just tried your demo using Safari on a Macintosh and the control doesn't work (the Javascript popup doesn'tn show up). It shows up as it should on IE.

    Thought you'd like to know

    W

Comments have been disabled for this content.