The parent page JS gets the value selected in the pop-up window. When the pop-up window is closed, refresh the parent page.

Source: Internet
Author: User

I. Obtain the pop-up window value from the parent page Js.
This page uses a textbox to receive the passed value.
<Input id = "text1" type = "text" onclick = "show ();" runat = "server"/>
Function show ()
{
VaR result = Window. showmodaldialog ("Top. aspx", null, "dialogwidth: 350px; dialogheight: 350px; help: No; Status: No ");
If (result)
{
VaR A = Document. getelementbyid ("text1 ");
A. value = result;
// Alert (result );
}
Else
{
Alert ('subwindow returns false! ');
}
}

Pop-up page
Add <base target = "_ Self"> </base>

Return Value
String A = "successfully passed the value ";
Response. Write ("<SCRIPT> window. returnvalue = '" + A + "'; window. Close (); </SCRIPT> ");

Ii. Close the pop-up window and refresh the parent page
Parent page
<SCRIPT type = "text/JavaScript">
Function show ()
{
// Method 1 in the pop-up window:
// Window. showmodaldialog ("defa3.3.aspx", null, "dialogwidth: 350px; dialogheight: 350px; help: No; Status: No ");
// Method 2 of the pop-up window:
Window. open ("defa3.3.aspx", null, "toolbar = No, location = No, directories = No, status = No, menubar = No, scrollbars = No, resizable = No, width = 400, Height = 200, Left = 300, Top = 400 ");
/}
</SCRIPT>

Pop-up page
<% @ Page Language = "C #" autoeventwireup = "true" codefile = "default3.aspx. cs" inherits = "default3" %>

<! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<HTML xmlns = "http://www.w3.org/1999/xhtml">
<Head runat = "server">
<Title> No title page </title>
<Base target = "_ Self"> </base>
</Head>
<Body>
<Form ID = "form1" runat = "server">
<Div>
Pop-up page
<Asp: button id = "button2" runat = "server" onclick = "button2_click" text = "button"/> </div>
</Form>
</Body>
</Html>

Code:

Protected void button2_click (Object sender, eventargs E)
{
Response. Write ("<SCRIPT> window. opener. Location. Reload (); window. Close (); </SCRIPT> ");
}

 

 

 

 

Refresh the framework parent page

Response. Write ("<SCRIPT> window. Open ('err. aspx ',''); window. Parent. Location. Reload (); </SCRIPT> ");

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.