新しい親ウィンドウページを作成します:
次のスクリプトを追加します
コードコピーは次のとおりです。
<html xmlns = "http://www.w3.org/1999/xhtml">
<head runat = "server">
<title> first </title>
</head>
<script type = "text/javascript">
関数showdialog(url)
{
var iWidth = 560; //モーダルウィンドウの幅
var iheight = 300; //モーダルウィンドウの高さ
var itop =(window.screen.height-height-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;場所:no;
document.getElementById( "textbox1")。innertext = returnValue;
}
</script>
<body>
<form id = "form1" runat = "server">
<入力id = "button1" type = "button" value = "button" onclick = "showdialog( './ second.aspx')" />
<div> <asp:textbox id = "textbox1" runat = "server" width = "67px"> </asp:textbox> </div>
</form>
</body>
</html>
second.htmlページを作成します。
コードコピーは次のとおりです。
<html xmlns = "http://www.w3.org/1999/xhtml">
<head runat = "server">
<title> second </title>
<! - <ベースターゲット= "_ self"> </base> - >
</head>
<スクリプト言語= "javascript">
function closediag()
{
window.opener = null;
window.close();
}
function ok()
{
var value = document.getElementsbyname( "myradio");
for(var i = 0; i <value.length; i ++)
{
if(value [i] .cecked)
{
window.returnvalue = value [i] .value;
window.close();
}
それ以外
{
document.getElementById( "lab_info")。innertext = "選択されたアイテムなし、選択!";
}
}
}
</script>
<body>
<form id = "form1" runat = "server">
<div>
<asp:datagrid id = "dgsjygl" runat = "server" lockpaging = "true" autogeneratecolumns = "false"
backcolor = "white" font-size = "9pt" pagesize = "5" width = "100%" height = "127px" onitemdatabound = "dgsjygl_itemdatabound">
<PagerSyle Mode = "numericPages" />
<allatingItemStyle backcolor = "Gainsboro" />
<itemstyle backcolor = "#eeeee" forecolor = "black" horizontalAlign = "center" />
<columns>
<ASP:TemplateColumn>
<headertemplate>
<label> select </label>
</headertemplate>
<itemtemplate>
<入力型= "Radio" id = "myradio" name = "myradio" value = '<%#databinder.eval(container.dataitem、 "id")%>'>
</itemtemplate>
<headertyle font-bold = "true" horizontalAlign = "center" width = "60px" />
<itemstyle horizontalAlign = "center" />
</asp:templatecolumn>
<asp:boundcolumn datafield = "id" headertext = "no。">
<headerSyle font-bold = "true" width = "75px" horizontalAlign = "center"/>
</asp:boundcolumn>
<asp:boundcolumn datafield = "mc" headertext = "name">
<headersyle font-bold = "true" width = "90px" horizontalAlign = "center"/>
<itemstyle horizontalAlign = "center" />
</asp:boundcolumn>
<asp:boundcolumn datafield = "bt" headertext = "title">
<headersyle font-bold = "true" horizontalAlign = "center"/>
</asp:boundcolumn>
</列>
<headertyle backcolor = "#7481ba" forecolor = "yellow" font-bold = "false" font-italic = "false" font-overline = "false" font-strikeout = "false" font-size = "small" />>
</asp:datagrid>
</div>
<div>
<入力ID = "btn_ok" type = "button" onclick = "ok()" value = "ok"/>
<入力ID = "btn_cancel" type = "button" onclick = "clickdiag()" value = "cancel" />
</div>
</form>
</body>
</html>
上記は、この単純な関数を実装することです。もっと便利な方法があるべきだと思います。ご存知の場合は、説明するためにメッセージを残してください。