JavaScript to bring up the child window and pass the value to the parent window, javascript window
Create parent window page:
Add the following script
Copy codeThe Code is as follows:
<Html xmlns = "http://www.w3.org/1999/xhtml">
<Head runat = "server">
<Title> First </title>
</Head>
<Script type = "text/javascript">
Function ShowDialog (Url)
{
Var iWidth = 560; // The width of the modal window.
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')"/>
<Div> <asp: TextBox ID = "TextBox1" runat = "server" Width = "67px"> </asp: TextBox> </div>
</Form>
</Body>
</Html>
Create the second.html page:
Copy codeThe Code is as follows:
<Html xmlns = "http://www.w3.org/1999/xhtml">
<Head runat = "server">
<Title> second </title>
<! -- <Base target = "_ self"> </base> -->
</Head>
<Script language = "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]. checked)
{
Window. returnValue = Value [I]. value;
Window. close ();
}
Else
{
Document. getElementById ("Lab_Info"). innerText = "no selection. Please select! ";
}
}
}
</Script>
<Body>
<Form id = "form1" runat = "server">
<Div>
<Asp: DataGrid ID = "dgSjygl" runat = "server" AllowPaging = "True" AutoGenerateColumns = "False"
BackColor = "White" Font-Size = "9pt" PageSize = "5" Width = "100%" Height = "pixel PX" OnItemDataBound = "dgSjygl_ItemDataBound">
<PagerStyle Mode = "NumericPages"/>
<AlternatingItemStyle BackColor = "Gainsboro"/>
<ItemStyle BackColor = "# EEEEEE" ForeColor = "Black" HorizontalAlign = "Center"/>
<Columns>
<Asp: TemplateColumn>
<HeaderTemplate>
<Label> select </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 = "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>
</Columns>
<HeaderStyle BackColor = "# 7481BA" ForeColor = "Yellow" Font-Bold = "False" Font-Italic = "False" Font-Overline = "False" Font-Strikeout = "False "Font-Underline =" False "Font-Size =" Small "/>
</Asp: DataGrid>
</Div>
<Div>
<Input id = "Btn_ OK" type = "button" onclick = "OK ()" value = "OK"/>
<Input id = "Btn_Cancel" type = "button" onclick = "clickDiag ()" value = "Remove"/>
</Div>
</Form>
</Body>
</Html>
The above is all about implementing this simple function. I feel that there should be more convenient methods. If you know it, please leave a message to explain it.