สร้างหน้าหน้าต่างหลักใหม่:
เพิ่มสคริปต์ต่อไปนี้
การคัดลอกรหัสมีดังนี้:
<html xmlns = "http://www.w3.org/1999/xhtml">
<head runat = "เซิร์ฟเวอร์">
<title> อันดับแรก </title>
</head>
<script type = "text/javascript">
ฟังก์ชั่น showdialog (URL)
-
var iwidth = 560; // ความกว้างของหน้าต่างโมดัล
var iheight = 300; // ความสูงของหน้าต่างโมดัล
var itop = (window.screen.height-ifeight-100)/2;
var ileft = (window.screen.width-iwidth)/2;
var returnValue = window.ShowModaldialog (url, "newwindow", "dialogheight:"+iheight+"px; dialogwidth:"+iwidth+"px; แถบเครื่องมือ: ไม่; menubar: ไม่;
document.getElementById ("textbox1"). innerText = returnValue;
-
</script>
<body>
<form id = "form1" runat = "เซิร์ฟเวอร์">
<input id = "button1" type = "button" value = "ปุ่ม" onclick = "showdialog ('./ second.aspx')" />
<div> <asp: textbox id = "textbox1" runat = "เซิร์ฟเวอร์" width = "67px"> </asp: textbox> </div>
</form>
</body>
</html>
สร้างหน้า second.html:
การคัดลอกรหัสมีดังนี้:
<html xmlns = "http://www.w3.org/1999/xhtml">
<head runat = "เซิร์ฟเวอร์">
<title> วินาที </title>
<!-<base target = "_ self"> </base>->
</head>
<ภาษาสคริปต์ = "JavaScript">
ฟังก์ชั่น floseiag ()
-
window.opener = null;
window.close ();
-
ฟังก์ชั่นตกลง ()
-
var value = document.getElementsByName ("myradio");
สำหรับ (var i = 0; i <value.length; i ++)
-
ถ้า (ค่า [i]. ตรวจสอบ)
-
Window.ReturnValue = ค่า [i] .Value;
window.close ();
-
อื่น
-
document.getElementById ("lab_info"). innerText = "ไม่มีรายการที่เลือกโปรดเลือก!";
-
-
-
</script>
<body>
<form id = "form1" runat = "เซิร์ฟเวอร์">
<div>
<ASP: dataGrid id = "dgsjygl" runat = "เซิร์ฟเวอร์" leverpaging = "true" autogenerateColumns = "false"
backcolor = "สีขาว" font-size = "9pt" pagesize = "5" ความกว้าง = "100%" ความสูง = "127px" onitemdatabound = "dgsjygl_itemdatabound">
<pegerstyle mode = "NumericPages" />
<soldnatingItemstyle backcolor = "Gainsboro" />>>
<itemstyle backcolor = "#eeeeee" porecolor = "black" horizontalalign = "center" />>>>>
<คอลัมน์>
<ASP: Templatecolumn>
<HeaderTemplate>
<label> เลือก </label>
</headerTemplate>
<ItemTemplate>
<input type = "Radio" id = "myradio" name = "myradio" value = '< %# databinder.eval (container.dataiTem, "id") %>'>
</itemTemplate>
<headerstyle font-bold = "true" horizontalalign = "center" width = "60px" />
<itemstyle horizontalalign = "center" />
</asp: Templatecolumn>
<ASP: BoundColumn DataField = "id" headerText = "ไม่">
<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>
</คอลัมน์>
<HeaderStyle backcolor = "#7481BA" PORESTOLOR = "เหลือง" font-bold = "false" font-italic = "false" font-fontline = "false" font-strikeout = "false" font-underline = "false" font-size = "small" />>>>>>>
</asp: dataGrid>
</div>
<div>
<อินพุต id = "btn_ok" type = "ปุ่ม" onclick = "ตกลง ()" value = "ตกลง"/>
<อินพุต id = "btn_cancel" type = "ปุ่ม" onclick = "clickdiag ()" value = "ยกเลิก" />
</div>
</form>
</body>
</html>
ข้างต้นคือทั้งหมดที่เกี่ยวกับการใช้ฟังก์ชั่นง่าย ๆ นี้ ฉันรู้สึกว่าควรมีวิธีที่สะดวกกว่า หากคุณรู้โปรดฝากข้อความไว้เพื่ออธิบาย