asp.net dialogs aren't impossible
Custom Dialogs in asp.net
It seemed like they'd always be a real pain, until Jesse Ezell blogged about his team's frustration with it, along with some neato example code for how they solved it. It was a great idea, and Jesse should definitely be praised for posting it to the community.
However, typical me, I wanted a better Plop-It-In© experience with the dialog control. I was also a little unhappy with a couple aspects of it, such as violating the rule of Thou Shalt Not Call __doPostBack Directly. So I started pounding out code.
The first thing I did was reorganize everything so that handling the standard dialog was simply a matter of adding event handler that got the results. However, the first time I went to test my new creation... my Google Toolbar Popup Blocker blocked the popup dialog. D'oh. This was because the window.open was written to the postback's response stream from a serverside call to Open. Holding down ctrl quickly got old. So I added button and linkbutton controls that are pointed at dialog window controls, and open the dialog immediately on clientside click, thus eliminating both the popup blocker problem and the extra postback.
After that initial framework was done, I was thinking hey, I should provide some useful generic dialogs in the box... And since jscript is missing the InputBox and flexible MessageBox of VB, I figured those would be great candidates. I decided to implement them using classes inside the assembly, using the IHttpHandler interface stuff. There is a bit of Good vs. Bad in that decision. Good: Only one file, the control assembly, needs to be kept track of by the app developer. Bad: The handler factory needs to be registered in web.config or the built in dialogs don't work. And what made the Bad even worse, was that there's no api to determine if handlers are registered. But in the end I decided to stick with a handler factory, because, well, I think they are cool and ultimately easier to manage.
The actual implementation of the InputBox and MessageBox are fairly vanilla. They derive from DialogPage, which derives from Page, so I got the IHttpHandler implementation for free. They are basically just no-declaration aspx files embedded in my assembly. The messagebox does have one neat thing tho. It includes the standard messagebox icons like the exclamation point and stop sign. To do this, I added gifs of the icons as embedded resources, and included an IHttpHandler which reads the image resources and writes it to the response stream. very nifty... and another reason why I went with handlers instead of external files.
Oh, ya, make that a few more neat things. Both InputBox and MessageBox use system colors on systems that can do it. Under mozilla, it actually looks like a real dialog box, while IE still has a system window border. Oh, and I even did a little guesstimating to try to make sure that the messagebox is always big enough to hold the prompting text you give it.
The only thing i'm not happy with right now is that the dialogs aren't modal. I plan on correcting that in the future, but since it's a big browser-compat problem, I decided to release what I have now, and work on that for v2.
Anyway, I really hope everybody, and especially Jesse, find my version of the dialog control as useful and neat as I did.