This tutorial begins with basic HTML showing how to set data on a Modal Dialog and return that data to the original page using Javascript. There are a few tricks which will be illustrated that you'll have to use if you want to get the same functionality with ASP.NET pages.
I've seen similar tutorials and samples on the web. Some claim to have modal dialogs but still allow clicking on the main window. Most don't show how to return multiple values from the dialog.
Included in the .zip file is a web page called Instructions.htm which (you guessed it) includes tutorial instructions.
The HTML source is in the HTML directory and the ASP.NET (C#) Project is in the DialogAspx directory.
I have only tested on Internet Explorer 6.0 but I believe it will also work on IE 5.0.
Please rate and post comments.
Enjoy!
Terms of Agreement:
By using this article, you agree to the following terms...
You may use
this article in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
You MAY NOT redistribute this article (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.
You may link to this article from another website, but ONLY if it is not wrapped in a frame.
You will abide by any additional copyright restrictions which the author may have placed in the article or article's description.
Planet Source Code doesn't allow HTML tags anymore :(
See Instructions.htm
Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. Afterdownloading it, you will need a program like Winzip to decompress it.Virus note:All files are scanned once-a-day by Planet Source Code for viruses, but new viruses come
out every day, so no prevention program can catch 100% of them. For your own safety, please:
Re-scan downloaded files using your personal virus checker before using it.
NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.
If you don't have a virus scanner, you can get one at many places on the net
including:McAfee.com
Terms of Agreement:
By using this article, you agree to the following terms...
You may use
this article in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
You MAY NOT redistribute this article (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.
You may link to this article from another website, but ONLY if it is not wrapped in a frame.
You will abide by any additional copyright restrictions which the author may have placed in the article or article's description.
Clear explanation! Good trick! Thanks. (If this comment was disrespectful, please report it.)
11/6/2004 8:06:35 AM:
when i put your code in my iis server of windows 2000,in local machine it is very good. but when i access the page from other pc(win98,ie5.0),i click then ok button of child windows,the other child window display. can you tell me how to solve the problem. thank you very much. (If this comment was disrespectful, please report it.)
There is very little C# code in the project as it is mostly javascript. The only thing you need to know is how to add an attribute to a button.
In C# the syntax is: button.Attributes["onclick"] = "javascript: return Function();"; OR button.Attributes.Add("onclick", "javascript: return Function();");
In VB it's: button.Attributes("onclick") = "javascript: return Function();" OR button.Attributes.Add("onclick", "javascript: return Function();") (If this comment was disrespectful, please report it.)
This sample/tutorial is fantastic! But, I had to change the child.aspx body section to this:
BODY onLoad="javascript:GetData()"; MS_POSITIONING="GridLayout"
The difference from the sample is the addtion of "javascript:" before GetData(). Without that I got an error in the script on this page... "Object Expected".
Works 100% with that (VS.NET 2003) I can go crazy with dialogs to get user input now! (If this comment was disrespectful, please report it.)
Wait! My bad! I didn't realize that the onload=gETdATA() was cASE sENSTIVE! Forget that javascript: thing I added. It works with or without it. I had getdata() not GetData(). Sorry! (If this comment was disrespectful, please report it.)
Fantastic... good job... (If this comment was disrespectful, please report it.)
Add Your Feedback
Your feedback will be posted below and an email sent to
the author. Please remember that the author was kind enough to
share this with you, so any criticisms must be stated politely, or they
will be deleted. (For feedback not related to this particular article, please
click here instead.)