472,099 Members | 2,266 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,099 software developers and data experts.

Modal dialog in web application

Hi!

I'm working on a web application in Asp.net and what I would like to
have is a cross borwser modal dialog which accepts user's input.

I would like to catch what the user clicked on the dialog. To be more
specific I want to have a confirmation dialog that is shown when a user
clicks on a Delete button (which deletes some values from database). If
Yes is pressed the delete action is processed otherwise modal dialog is
closed.

Modal dialog has to work with IE and Firefox so showModalDialog doesn't
count. Confirm (javascript) also doesn't count because the text on the
buttons must be set programmatically (localization).

I have found some pages (line this one:
http://javascript.about.com/library/blmodald1.htm) describing how to
work with modal dialogs, but I have trouble manipulating user's input.

Are there any solutions?

Thanks!

Sep 7 '06 #1
2 3575
Hi,

In a cross browser environment you can't do a modal dialog. The example from
the link is essentially clever tricks with divs (note that in the example
even when the "modal dialog" is shown the keyboard commands are still
working... eg. pressing tab will shift focus through the links on the page,
pressing Enter will activate the link).

So... you're either stuck with modal for IE only, non-model for non-IE. Or
change the interaction design (clicking delete goes to a confirmation page,
clicking confirm on that page does the actual deletion).

For modal IE dialogs if you are doing "things" by postback (forms
submissions) you might run into problems. IE modal dialogs don't like
postbacks... you have to wrap do everything in an iframe and do the post
backs there. A bit messy feeling... but not so bad once you've got it
working.

With non-IE part of the "trick" is having the parent window react once the
user has finished doing something. The "window.parent" and
"window.parent.opener" is your friend here.

Here's a sample script that will call "DoMyThing" in the parent/opener. This
assumes the use of the outer/inner document via an IFRAME, and it is careful
to be cross browser (if dialogArguments exists it uses that... which is IE
specific). It is also careful to handle wierd situations (the original
window has been closed or the user has navigated away from the original
page):

<SCRIPT TYPE="text/javascript">
if (!window.parent)
window.close();
else
{
var opener;
if (window.parent.dialogArguments)
opener = window.parent.dialogArguments;
else
opener = window.parent.opener;
if (opener && !opener.isClosed)
{
if (opener.AddNewUser)
{
try {
opener.DoMyThing();
} catch (ex) { }
}
}
window.parent.close();
}
</script>

Hope that all makes sense :)

Rob MacFadyen

ps. One last note... when opening windows and hiding tool bars and such...
don't bother trying to hide the status bar. More and more this is being
disallowed for security reasons... so you're better off always showing it
and adjust the visual design to accomedate it.
<st******@gmail.comwrote in message
news:11**********************@h48g2000cwc.googlegr oups.com...
Hi!

I'm working on a web application in Asp.net and what I would like to
have is a cross borwser modal dialog which accepts user's input.

I would like to catch what the user clicked on the dialog. To be more
specific I want to have a confirmation dialog that is shown when a user
clicks on a Delete button (which deletes some values from database). If
Yes is pressed the delete action is processed otherwise modal dialog is
closed.

Modal dialog has to work with IE and Firefox so showModalDialog doesn't
count. Confirm (javascript) also doesn't count because the text on the
buttons must be set programmatically (localization).

I have found some pages (line this one:
http://javascript.about.com/library/blmodald1.htm) describing how to
work with modal dialogs, but I have trouble manipulating user's input.

Are there any solutions?

Thanks!

Sep 7 '06 #2
You can also create modal dialog with window.open (which works with
Firefox), I've used that techniwue in my blog post

ASP.NET: causing a postback after modal dialog is closed
http://aspadvice.com/blogs/joteke/ar.../05/20331.aspx

Essentially the relevamnt snippet there is:

if(window.showModalDialog)
{
var args=new Object();
args.window = window;
args.doPostBack = doPostBack;

window.showModalDialog('Dialog.aspx', args);
}
else
{
window.open('Dialog.aspx','','modal=yes');
}

Of course with arguments to window.open and showModalDialog, you have more
control over the size etc of the dialog window.
--
Teemu Keiski
ASP.NET MVP, AspInsider
Finland, EU
http://blogs.aspadvice.com/joteke
<st******@gmail.comwrote in message
news:11**********************@h48g2000cwc.googlegr oups.com...
Hi!

I'm working on a web application in Asp.net and what I would like to
have is a cross borwser modal dialog which accepts user's input.

I would like to catch what the user clicked on the dialog. To be more
specific I want to have a confirmation dialog that is shown when a user
clicks on a Delete button (which deletes some values from database). If
Yes is pressed the delete action is processed otherwise modal dialog is
closed.

Modal dialog has to work with IE and Firefox so showModalDialog doesn't
count. Confirm (javascript) also doesn't count because the text on the
buttons must be set programmatically (localization).

I have found some pages (line this one:
http://javascript.about.com/library/blmodald1.htm) describing how to
work with modal dialogs, but I have trouble manipulating user's input.

Are there any solutions?

Thanks!

Sep 7 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Gilles T. | last post: by
3 posts views Thread by Cosh | last post: by
3 posts views Thread by Andrew | last post: by
10 posts views Thread by Guadala Harry | last post: by
1 post views Thread by Ganesh Ramamurthy | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.