Assume that the ParentForm. aspx page contains TextBox1 text box and Open button.
Click the Open button to bring up SubForm. aspx. The SubForm. aspx page contains the TextBox1 text box and the Close button.
Click Close to Close the SubForm. aspx page, and display the value of the SubForm. aspx text box on the subpage to the ParentForm. aspx text box on the parent page.
Front-end code of the parent form:
Copy codeThe Code is as follows:
<Script type = "text/javascript">
Function OpenSubForm (ret ){
Var strPath = "subForm. aspx"
Var nHeight = 500
Var nWidth = 500
Var feature
Feature = "Height =" + nHeight + ", Width =" + nWidth + ", top = 30, Left = 30 ";
Feature + = ", dependent = yes, location = no, resizable = yes, scrollbars = yes, status = yes, toolbar = no ;";
Window. open (strPath + "? Ret_Form = Form1 & Ret_Value = "+ ret, 'subform', feature). focus ();
Return false;
}
</Script>
Background code of the parent form:
Copy codeThe Code is as follows:
Private void Page_Load (object sender, System. EventArgs e)
{
// Zookeeper early stage of transformation zookeeper
This. Button1.Attributes. Add ("onClick", "return OpenSubForm ('textbox1 ');");
}
Subform background code:
Copy codeThe Code is as follows:
Private void button#click (object sender, System. EventArgs e)
{
String strScript = string. Empty;
String strRetForm = String. Empty;
String strRetValue = String. Empty;
StrRetForm = Request. Params ["Ret_Form"];
StrRetValue = Request. Params ["Ret_Value"];
If (strRetForm = string. Empty)
{
StrRetForm = "document. forms [0]";
}
StrScript = "<script language = javascript> ";
StrScript + = "window. opener." + strRetForm;
StrScript + = "." + strRetValue + ". value = '" + this. TextBox1.Text. Trim () + "';";
StrScript + = "window. close ();";
StrScript + = "</script> ";
Response. Write (strScript );
}