I have two pages. The homepage is add_rz.aspx, And the subpage is open_kh.aspx. In order to realize the subpage value passing to the parent page, I found some implementation methods on the Internet. Later, because the project needs to be modified to two different main forms to share one subform.
Select the selection button in the gridview of the child page, and pass the value to the parent page for display.
Add JavaScript to the parent formCodeAs follows.
<Script language = "JavaScript">
Function choosekh_show (OBJ)
{
Window. open ("openfind_kh.aspx", "xuanze", "width = 800, Height = 600, Top = 20, Left = 200, toolbar = No, menubar = No, scrollbars = Yes, resizable = Yes, location = No, status = No ");
}
</SCRIPT>
"Xuanze" indicates that the window is accessed by a specific name.
Subpage Javascript
Function choose (kind, KH)
{
Try
{
If (window. Parent. Name = "xuanze ")
{
Using Role opener.doc ument. getelementbyid ("ctl00_contentplaceholder1_txtkh"). value = kind;
Optional values opener.doc ument. getelementbyid ("ctl00_contentplaceholder1_txtkhname"). value = KH;
}
Else
{
Optional values opener.doc ument. getelementbyid ("txtkh"). value = kind;
}
}
Catch (e ){}
Window. Close ();
}
The subpage calls Javascript in the rowdatabound event of the gridview.
If (E. Row. rowtype = datacontrolrowtype. datarow)
{
String kind = E. Row. cells [0]. text;
String kh = E. Row. cells [1]. text;
Ch. Attributes. Add ("onclick", "javascript: Choose ('" + kind + "', '" + KH + "');");
}
Parent page
Subpage