Introduction

As web developers, we always need model windows. But the simplest model window that comes from JavaScript has a problem: "Popup Blockers". You can write window.showModalDialog(...) in script, but what next?

My component, a web message box is a customizable modal dialog for ASP.NET 2.0, but not a popup and not a new window. It appears at the top of all objects and hides the others, so the other controls can not be clicked.

Background

The idea is very simple. In m control, I have some panels (<div>) and their z-indexes. I open a transparent panel at the top of all elements. So I prevent them being clicked. Then, I need a few new panels for the messagebox and some scripting and styling to show them.

The control has three events:

Btn1Clicked

Btn2Clicked

Btn3Clicked

Two styles:

msg.MessageBoxStyle.Violet

msg.MessageBoxStyle.Blue

And four icons:

msg.MessageBoxIcons.Exclamation

msg.MessageBoxIcons.Asteriks

msg.MessageBoxIcons.Question

msg.MessageBoxIcons.None

You can edit the visual affects by editing the InitializeIcon and InitializeStyle functions in Mbox.ascx.cs.

Using the control

Only thing you should do is add the Mbox.ascx user control and the Resources folder to your project. And then drag & drop the user control to your web form.

Add the following code to your default.aspx or whatever your file is..

I will not tell you more about this message box. I told you the logic behind it. A little effort will be enough to understand the code.

Points of Interest

The next version of the product will be a window-like popup control, but of course not a popup. It will be available soon... For bug reports and suggestions, I will wait for your mails at ozuolmez@msn.com.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

It all works great for me except for one thing. After the button handler executes the browser does not reflect the visual changes I made in the event. For example, I hide a panel control that is visible before the message box. After the message box, the panel is still visible even though I set its Visible property to false. Also, when I try to show a hidden control in the button handler, it does not show...

It all works great for me except for one thing. After the button handler executes the browser does not reflect the visual changes I made in the event. For example, I hide a panel control that is visible before the message box. After the message box, the panel is still visible even though I set its Visible property to false. Also, when I try to show a hidden control in the button handler, it does not show...

Hello,
I used your excellent code of the MessageBox, but I had small problem.
Is there a way to manually change the location of the control?
Basicly, I'm asking the same question as rchokler asked you on 12:24 3 Apr '06

Great Control!! It works fine in the VS 2005 development environment. However after publishing the WEB site and run from the browser Mbox appearance changes. Entire contentplaceholder becomes Gray color and Mbox popup background changes to black. Do you know the reason for this?

Yeeow, i found the reason, the problem are the form layers, you must to put messagebox over the most external layer, if you have your form statements next to bodies statements the most external one of the layers will be all the page, and you will see this bad behavior.

try changing the position of your <form> and </form> statements send them to inside the code page, all you can...

As this solution doesn't work for me (and i don't know why, cause i do not know javascript) i digged more, what took me over 2 days (i'm new to asp.net though) and i do not really know, why haven't yet anybody posted solution i'm going to give here, because when you'll see it, you certainly will agree with me, that all those mvp's and other great guys had to know it.

So to make this great control work in all common *.aspx and in the ones bounded to some ContentPlaceHolder:
- open the behind cs code file
- find the one of the overloaded Show methods that invokes ShowPowWin script
- it gives the script three parameters - third is the ID of the control to show, but ID is the ID of control in the ascx file, but we need ID of the control in the entire page which differs f.e. when mbox is placed in ContentPlaceHolder (you can see this when you open source of page shown in your IE or sth)
- change this.ID to this.ClientID, which is generated on fly by framework when it is generating the page for the request

That's all ! I specially made account here, to write this and save some other people hours of searching and frustration - because if i didn't find this solution i would certainly depracete it and never use anymore.

Hello,
I used your wonderful code of the Server Side MessageBox, but I had small problem.
I couldn’t find how to relocate the Message window, it always appear in the middle of the page,
Can I change the location ?

As this solution doesn't work for me (and i don't know why, cause i do not know javascript) i digged more, what took me over 2 days (i'm new to asp.net though) and i do not really know, why haven't yet anybody posted solution i'm going to give here, because when you'll see it, you certainly will agree with me, that all those mvp's and other great guys had to know it.

So to make this great control work in all common *.aspx and in the ones bounded to some ContentPlaceHolder:
- open the behind cs code file
- find the one of the overloaded Show methods that invokes ShowPowWin script
- it gives the script three parameters - third is the ID of the control to show, but ID is the ID of control in the ascx file, but we need ID of the control in the entire page which differs f.e. when mbox is placed in ContentPlaceHolder (you can see this when you open source of page shown in your IE or sth)
- change this.ID to this.ClientID, which is generated on fly by framework when it is generating the page for the request

That's all ! I specially made account here, to write this and save some other people hours of searching and frustration - because if i didn't find this solution i would certainly depracete it and never use anymore.

Hi my friend, if you get error on the keyword "partial" your problem is so simple and so big. you have problem with your version of .NET FW Because, as you could see in the article, this component is written for ASP.NET 2.0, so you need .NET FW 2.0

if it still does not work, please feel free to ask and search for help.

Did you download the source files and look at them to see what is differnt about your code?

"Art doesn't want to be familiar. It wants to astonish us. Or, in some cases, to enrage us. It wants to move us. To touch us. Not accommodate us, make us comfortable." -- Jamake HighwaterToasty0.comMy Grandkids

I have tried a number of div popup window solutions, most do not cope with a dropdown list showing through in IE.
The normal technique is the put an iframe shim below the window div, as this is the only object that is opaque to a dropdown list.