NewsFeed   -
KỸ THUẬT LẬP TRÌNH
S  M  L
Modal Popup Dialog Window in ASP.NET - Script

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.
Scope: ASP, ASP.NET, C#, Csharp, VB.NET, Visual Basic, Java

1. Open a New Web project in Visual Studio
2.
Create two New WebForm pages named ParentWebForm and ChildWebForm
3.
Open the HTML surface for the ParentWebForm
4.
Locate the yellow line
5.
Delete all code EXCEPT the yellow line
6.
Insert the following HTML below the existing yellow line

DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<
HTML>
<HEAD>
<title>Parent Webformtitle>
<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 WindowBUTTON>P>
body>
HTML>

7. In the above code, locate the line saying //ALTER BELOW LINE
8. Supply the correct URL for your Child Webform
9. Open the HTML surface for the ChildWebForm
10. Locate the yellow line
11. Delete all code EXCEPT the yellow line
12. Insert the following HTML below the existing yellow line

DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<
HTML>
<HEAD>
<TITLE>Child WebformTITLE>
<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">OKBUTTON>
BODY>
HTML>

13. Set the project StartUp page to be the Parent Webform
14. Run the project.

Final Note: To make the child modal to the entire desktop, you'll need add code to the child which uses <body onblur="this.focus">.

- 04/28/2011
Search:
NGHỆ THUẬT - PHIM - ẢNH

HÌNH ẢNH ĐẸP

Photo

Album: Ảnh Nghệ Thuật
< July 2011 >
Sun Mon Tue Wed Thu Fri Sat
26 27 28 29 30 1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
31 1 2 3 4 5 6
More... (All Collections)
H2O NEWS

Everything Meaning To You!

Email: [email protected]

Website: emty.org

Liên hệ

Đặt làm trang chủ

@