?
Solved

Close popup from Parent window link

Posted on 2009-03-31
11
Medium Priority
?
1,023 Views
Last Modified: 2012-05-06
I have a parent window with two LinkButtons, one is to open the popup and one is to close the popup, it is opening the popup but it not closing and when the Close popup link is clicked in the parent window then  the popup should gets close and parent should redirect.
please help its urgent
Design Aspx page
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="testt.aspx.cs" Inherits="TrainingCenter_testt" %>
 
<!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>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        &nbsp;
                <asp:LinkButton ID="LinkButton1" runat="server" OnClick="LinkButton1_Click">Open Popup</asp:LinkButton><br />
                <br />
                <br />
                <br />
                <asp:LinkButton ID="LinkButton2" runat="server" OnClick="LinkButton2_Click">Close popup</asp:LinkButton>
        <br />
        <br />
        <br />
    
    </div>
    </form>
</body>
</html>
 
 
 
 
 
Code file
 
public partial class TrainingCenter_testt : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
 
    }
    protected void LinkButton1_Click(object sender, EventArgs e)
    {
        ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "pop", "var child1=window.open('popup.aspx',null,'height=300,width=575,location=no,status=no,toolbar=no,dialog=yes,resizable=no')", true);
    }
    protected void LinkButton2_Click(object sender, EventArgs e)
    {
        ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "pop", "parent.child1.close()", true);
        Response.Redirect("~/Login.aspx");
    }
}

Open in new window

0
Comment
Question by:mannevenu
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 5
11 Comments
 
LVL 28

Expert Comment

by:sybe
ID: 24037083
"parent.child1.close()" -> "this.child1.close();"

0
 

Author Comment

by:mannevenu
ID: 24037186
No its not working
only the parent page is getting redirected but popup is still opened but my requirement is parent page should be redirected and child popup should be closed
0
 
LVL 28

Expert Comment

by:sybe
ID: 24037218
Any javascript errors? What does the HTML-source of the page look like?

Using PostBack will load the same page again, but reloading the page will disconnect the popup from the page. You might want to write the "linkbutton" in plain HTML and/or not have it runat="server".

0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:mannevenu
ID: 24037442
I have already given the source just copt and paste it in ur new aspx page
and code in aspx.cs file
0
 
LVL 28

Expert Comment

by:sybe
ID: 24037478
> I have already given the source just copt and paste it in ur new aspx page

You did not give the HTML-source. Open the page in your browser and do a "view source".
0
 

Author Comment

by:mannevenu
ID: 24037823
<!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><title>
      Untitled Page
</title>
   <script type="text/javascript" language="javascript">
   function closepopup()
   {
   parent.child1.close();
   }</script>
</head>
<body>
    <form name="form1" method="post" action="testt.aspx" id="form1">
<div>
<input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" />
<input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="" />
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUKLTUyNDA3OTkxM2Rky01k4WMmCbB0X1c2zsj4CsLiVXM=" />
</div>

<script type="text/javascript">
<!--
var theForm = document.forms['form1'];
if (!theForm) {
    theForm = document.form1;
}
function __doPostBack(eventTarget, eventArgument) {
    if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
        theForm.__EVENTTARGET.value = eventTarget;
        theForm.__EVENTARGUMENT.value = eventArgument;
        theForm.submit();
    }
}
// -->
</script>


    <div>
       
                <a id="LinkButton1" href="javascript:__doPostBack('LinkButton1','')">Open Popup</a><br />
                <br />
        <span id="Label1"></span><br />
                <br />
                <a id="LinkButton2" href="javascript:__doPostBack('LinkButton2','')">Close popup</a>
           
        <br />
        <br />
        <br />
   
    </div>
    </form>
</body>
</html>
0
 
LVL 12

Expert Comment

by:Sinoj Sebastian
ID: 24037923
try this function


 
protected void LinkButton2_Click(object sender, EventArgs e)
    {
        ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "pop", "this.child1.close();window.location='Login.aspx'", true);
    }

Open in new window

0
 
LVL 28

Expert Comment

by:sybe
ID: 24037959
<a id="LinkButton2" href="javascript:__doPostBack('LinkButton2','')">Close popup</a>

This is not closing the popup, but posting the page to itself. What you need is this:

<a id="LinkButton2" href="javascript:closepopup();">Close popup</a>
0
 

Author Comment

by:mannevenu
ID: 24048286
yeah letme try this one
0
 
LVL 28

Accepted Solution

by:
sybe earned 2000 total points
ID: 24048397
alternatively you could have an unonload listener in the body

<body onunload="if(this.child1){this.child1.close();}">
0
 

Author Closing Comment

by:mannevenu
ID: 31565190
thank u sir its working
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question