A couple people have requested the source code for the ServerConfirm button I wrote. This adds a yes-no MessageBox to a regular html button. Clicking either yes or no triggers the appropriate server event.
Note that I wrote this version over a year ago, and there are some changes I would make:
- This is a custom-rendered control, which is created entirely from scratch - i.e. just html controls. It could be made as an extended control instead. This would still be compiled to a DLL and be reusable among ASP.Net projects (unlike UserControls), but would give the additional advantage of keeping all the WebControl.Button's extra properties that merely the Html button lacks.
I'll cover these in a future blog post. FYI, other blog posts related to this are:
- Passing client data to the server: http://timstall.dotnetdevelopersjournal.com/read/1118970.htm
With that all said, here's the source code below. It has three main regions:
- Public properties (Text for the button's text value, and Message for the MessageBox).
- Postback Data - handles posting data back to the server
- Postback Events - has a yes and no event