Buat halaman jendela induk baru:
Tambahkan skrip berikut
Salinan kode adalah sebagai berikut:
<html xmlns = "http://www.w3.org/1999/xhtml">
<head runat = "server">
<title> pertama </iteme>
</head>
<type skrip = "Teks/JavaScript">
Function Showdialog (URL)
{
var iwidth = 560; // Lebar jendela modal
var iheight = 300; // Modal Window Height
var itop = (window.screen.height-iheight-100)/2;
var ileft = (window.screen.width-iwidth)/2;
var returnValue=window.showModalDialog(Url, "newwindow", "dialogHeight:"+iHeight+"px; dialogWidth:"+iWidth+"px; toolbar:no; menubar:no; scrollbars:no; resizable:no; location:no; status:no; left:200px;top:100px;");
document.geteLementById ("TextBox1"). Innertext = returnValue;
}
</script>
<body>
<Form id = "Form1" runat = "server">
<Input ID = "Button1" type = "Button" value = "Button" OnClick = "ShowDialog ('./ Second.aspx')" />
<SEV> <ASP: TextBox ID = "TextBox1" runat = "server" width = "67px"> </asp: textbox> </div>
</form>
</body>
</html>
Buat halaman detik.html:
Salinan kode adalah sebagai berikut:
<html xmlns = "http://www.w3.org/1999/xhtml">
<head runat = "server">
<title> kedua </iteme>
<!-<base target = "_ self"> </ Base>->
</head>
<bahasa skrip = "javascript">
fungsi closeag ()
{
window.opener = null;
window.close ();
}
fungsi ok ()
{
var value = document.geteLementsByName ("myradio");
untuk (var i = 0; i <value.length; i ++)
{
if (nilai [i] .Cecked)
{
window.ReturnValue = nilai [i] .value;
window.close ();
}
kalau tidak
{
document.geteLementById ("lab_info"). Innertext = "Tidak ada item yang dipilih, silakan pilih!";
}
}
}
</script>
<body>
<Form id = "Form1" runat = "server">
<div>
<asp: datagrid id = "dgsjygl" runat = "server" allowpaging = "true" autogenerateColumns = "false"
Backcolor = "putih" font-size = "9pt" pageSize = "5" width = "100%" height = "127px" onItemDataBound = "dgsjygl_itemdatabound">
<Pagerstyle Mode = "numericpages" />
<BERGERBITANITEMSTYLE BACKOLOR = "GAINSBORO" />
<Itemstyle backcolor = "#eeeeeee" forecolor = "hitam" horizontalalign = "center" />
<columns>
<ASP: Templatecolumn>
<HeaderTemplate>
<label> SELECT </LABEL>
</Headertemplate>
<t itemtemplate>
<input type = "Radio" id = "myradio" name = "myradio" value = '< %# databinder.eval (container.dataitem, "id") %>'>
</TipTemplate>
<Headerstyle font-bold = "true" horizontalalign = "center" width = "60px" />
<Itemstyle horizontalalign = "center" />
</asp: Templatecolumn>
<asp: boundColumn dataField = "id" headertext = "no.">
<Headerstyle font-bold = "true" width = "75px" horizontalalign = "center"/>
</asp: BoundColumn>
<asp: boundColumn dataField = "mc" headertext = "name">
<Headerstyle font-bold = "true" width = "90px" horizontalalign = "center"/>
<Itemstyle horizontalalign = "center" />
</asp: BoundColumn>
<asp: boundColumn dataField = "bt" headertext = "title">
<Headerstyle font-bold = "true" horizontalalign = "center"/>
</asp: BoundColumn>
</solument>
<Headerstyle backcolor = "#7481ba" forecolor = "yellow" font-bold = "false" font-iTalic = "false" font-overline = "false" font-strikeout = "false" font-underline = "false" font-size = "kecil" />
</asp: datagrid>
</div>
<div>
<input id = "btn_ok" type = "tombol" onclick = "ok ()" value = "ok"/>
<input id = "btn_cancel" type = "tombol" ontClick = "clickDiag ()" value = "cancel" />
</div>
</form>
</body>
</html>
Di atas adalah semua tentang mengimplementasikan fungsi sederhana ini. Saya merasa bahwa harus ada cara yang lebih nyaman. Jika Anda tahu, silakan tinggalkan pesan untuk dijelaskan.