asp.net to select values from the pop-up window

Source: Internet
Author: User

asp.net To Select a value from the pop-up window in the

Article keywords: asp.net pop-up window value

In asp.net , it is a common way to pop the B page from page A and then close and update the data to a page after selecting the data in page B. It's just that I'm unfamiliar with JavaScript, so I worked on it all afternoon and finally got a little bit of success.

The test project has two pages: Default.aspx and Default2.aspx, on the Default.aspx page there is a TextBox1 and a button1,button1 used to trigger Default2.aspx,textbox1 to receive values from the child page.

The code for Button1 is as follows:

The following is a reference fragment:
StringBuilder s = new StringBuilder ();
S.append ("");
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 returning the selected CheckBoxList1 and closes the current page.

The code is as follows:

The following is a reference fragment:
protected void Button1_Click (object sender, EventArgs e)
{
StringBuilder s = new StringBuilder ();
S.append ("");
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;
}

It is important to execute the program at this time and not close it in the default2.aspx and not return the value:

In the head, join this line:

<base target= "_self"/>

Related Article

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.