![]() |
Web Development »
ASP.NET »
General
Intermediate
Modal popup dialog window with multiple parametersBy FlashMerlotModal popup dialog window which passes and returns multiple parameters |
C#, VB, Javascript.NET 1.0, .NET 1.1, Win2K, WinXP, Win2003, ASP, ASP.NET, Visual Studio, Dev
|
|
Advanced Search |
|
|
|
||||||||||||||||
This article shows a modal popup dialog window which passes and returns multiple parameters. This sample creates parent and child webforms. The child webform is called modally by the parent passing multiple values to the child form. The child form displays the passed values allowing them to be edited and then returns the altered values back to the parent when finished. The child form is modal to only the parent form. To make the child modal to the entire desktop, see the below final note.
ASP, ASP.NET, C#, VB.NET, Visual Basic, Java
WebForm pages named ParentWebForm and ChildWebForm
ParentWebForm
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>Parent Webform</title>
<script language="javascript">
function OpenChild()
{
var ParmA = retvalA.value;
var ParmB = retvalB.value;
var ParmC = retvalC.value;
var MyArgs = new Array(ParmA, ParmB, ParmC);
var WinSettings = "center:yes;resizable:no;dialogHeight:300px"
//ALTER BELOW LINE - supply correct URL for Child Form
var MyArgs = window.showModalDialog(
"http://localhost/ModalWin/ChildWebForm.aspx", MyArgs, WinSettings);
if (MyArgs == null)
{
window.alert(
"Nothing returned from child. No changes made to input boxes")
}
else
{
retvalA.value=MyArgs[0].toString();
retvalB.value=MyArgs[1].toString();
retvalC.value=MyArgs[2].toString();
}
}
</script>
</HEAD>
<body>
<P><INPUT id="retvalA" type="text" value="AAA"></P>
<P><INPUT id="retvalB" type="text" value="BBB"></P>
<P><INPUT id="retvalC" type="text" value="CCC"></P>
<P><BUTTON onclick="OpenChild()" type="button">
Open Child Window</BUTTON>
</P>
</body>
</HTML>
ChildWebform
ChildWebForm
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE>Child Webform</TITLE>
<script language="javascript">
function Done() {
var ParmA = tbParamA.value;
var ParmB = tbParamB.value;
var ParmC = tbParamC.value;
var MyArgs = new Array(ParmA, ParmB, ParmC);
window.returnValue = MyArgs;
window.close();
}
function doInit() {
var ParmA = "Aparm";
var ParmB = "Bparm";
var ParmC = "Cparm";
var MyArgs = new Array(ParmA, ParmB, ParmC);
MyArgs = window.dialogArguments;
tbParamA.value = MyArgs[0].toString();
tbParamB.value = MyArgs[1].toString();
tbParamC.value = MyArgs[2].toString();
}
</script>
</HEAD>
<BODY onload="doInit()">
<P>Param A:<INPUT id="tbParamA" TYPE="text"></P>
<P>Param B:<INPUT ID="tbParamB" TYPE="text"></P>
<P>Param C:<INPUT ID="tbParamC" TYPE="text"></P>
<BUTTON onclick="Done()" type="button">OK</BUTTON>
</BODY>
</HTML>
To make the child modal to the entire desktop, you'll need add code to the child which uses <body onblur="this.focus">.
General
News
Question
Answer
Joke
Rant
Admin
|
PermaLink |
Privacy |
Terms of Use
Last Updated: 13 Sep 2003 Editor: Nishant Sivakumar |
Copyright 2003 by FlashMerlot Everything else Copyright © CodeProject, 1999-2009 Web18 | Advertise on the Code Project |