ASP., select values from pop-up form (GO)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.