In ASP., it is a common way to pop the B page from page A and then close and update the data to page a when the data is selected on page B. It's just that I'm not familiar with JavaScript, so I've been tinkering with it all afternoon and finally got a little bit of a result:
The test project has two pages: Default.aspx and Default2.aspx, on the Default.aspx page there is a TextBox1 and a button1,button1 to trigger the Default2.aspx,textbox1 to receive the value returned from the child page.
The code for Button1 is as follows:
StringBuilder s = new StringBuilder ();
S.append ("<script language=javascript>");
S.append ("var a=window.showmodaldialog (' default2.aspx ');");
S.append ("if (a!=null)");
S.append ("document.all (' TextBox1 '). value=a;");
S.append ("</script>");
Type Cstype = this. GetType ();
ClientScriptManager cs = Page.clientscript;
String sname = "LT";
if (!cs. IsStartupScriptRegistered (Cstype, sname))
Cs. RegisterStartupScript (Cstype, Sname, s.tostring ());
The Default2.aspx page has a CheckBoxList1 and a button1,button1 executes the value of the CheckBoxList1 that returns the selection and closes the current page.
The code is as follows:
protected void Button1_Click (object sender, EventArgs e)
{
StringBuilder s = new StringBuilder ();
S.append ("<script language=javascript>" + "\ n");
S.append ("window.returnvalue=" + this. Getselectvalue () + "';" + "\ n");
S.append ("Window.close ();" + "\ n");
S.append ("</script>");
Type Cstype = this. GetType ();
ClientScriptManager cs = Page.clientscript;
String csname = "Ltype";
if (!cs. IsStartupScriptRegistered (Cstype, CSName))
Cs. RegisterStartupScript (Cstype, CSName, s.tostring ());
}
private String Getselectvalue ()
{
String rvalue = "";
for (int i = 0; I < this. CheckBoxList1.Items.Count; i++)
{
if (this. Checkboxlist1.items[i]. Selected)
{
if (rvalue = = "")
Rvalue + = this. Checkboxlist1.items[i]. Text;
Else
Rvalue + = "," + this. Checkboxlist1.items[i]. Text;
}
}
return rvalue;
}
At this point, it is important to execute the program, which is not closed in default2.aspx and cannot be passed back to the value:
In head, add this line:
<base target= "_self"/>
ASP., select values from pop-up form (GO)