Solved

How do i close pop up window after opening a document from a link in popup?

Posted on 2008-06-19
5
1,661 Views
Last Modified: 2012-08-14
i am implementing a functionality of check out. when i am click on check oot button a popup will open. In pop up we have a link button "Download", when the user click on this link we have to open a document and also we have to close pop up window. we are able to  open the document but not able to close the pop up window.
0
Comment
Question by:Parthap
[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
  • 2
  • 2
5 Comments
 
LVL 2

Expert Comment

by:vjc2003
ID: 21821171
how are you opening the document from the popup?
is window.close() not working?
0
 

Author Comment

by:Parthap
ID: 21821752
no window.close is not working.

on click event i set some value, and call Server.Execute() as shown below  

        Session["DocRef"] = Request.QueryString["DocRefNo"].ToString();
        Session["DocName"] = Request.QueryString["DocName"].ToString(); ;
        Session["DocExt"] = Request.QueryString["DocExt"].ToString(); ;
        Session["DocSec"] = Request.QueryString["DocSec"].ToString(); ;
        Session["DocVerNo"] = Request.QueryString["DocVer"].ToString(); ;
        Server.Execute("../Common/ViewDoc.aspx");
        Response.Write("<script>window.close();</script>");


In ../Common/ViewDoc.aspx  page i have write some code as shown below in Page_Load.

        Response.ClearContent();
        Response.ClearHeaders();
        Response.Buffer = true;
        Response.BufferOutput = true;

        Response.AddHeader("content-disposition", "attachment;filename=" + Session["DocName"].ToString());

       Byte[] bytBinaryReadContent = Convert.FromBase64String(strcontent);
            Response.BinaryWrite(bytBinaryReadContent);  

       Response.Flush();
       Response.Close();
0
 
LVL 5

Expert Comment

by:zeroxp
ID: 21828265
here is a little trick you can try: after you set all your session values, instead of do a Server.Execute open another download window before close the current popup.
//Set Session
//Session["DocRef"] = Request.QueryString["DocRefNo"].ToString();
//Session["DocName"] = Request.QueryString["DocName"].ToString(); ;
//Session["DocExt"] = Request.QueryString["DocExt"].ToString(); ;
//Session["DocSec"] = Request.QueryString["DocSec"].ToString(); ;
//Session["DocVerNo"] = Request.QueryString["DocVer"].ToString(); 
Response.Write("<script type=\"text/javascript\">window.open('../Common/ViewDoc.aspx'); window.close();</script>");
//more preferablely
ClientScript.RegisterClientScriptBlock(this.GetType(), "script01", "window.open('../Common/ViewDoc.aspx'); window.close();", true);
 
 
//in the ViewDoc.cs
byte[] buff = YOUCONTENT;
Response.Clear();
Response.AppendHeader("content-disposition", "attachment;filename=file.data");
Response.AppendHeader("Content-Length", buff.Length.ToString());
Response.BinaryWrite(buff);
Response.End();

Open in new window

0
 

Author Comment

by:Parthap
ID: 21844793
Hi,

//ClientScript.RegisterClientScriptBlock(this.GetType(), "script01", "window.open('../Common/ViewDoc.aspx'); window.close();", true);

I tried this also, but it can not open document. After click on link page is blank out and stuck there only.
0
 
LVL 5

Accepted Solution

by:
zeroxp earned 500 total points
ID: 21847435
my fault, should be:


but check your viewdoc form too. if it writes the file correct, it should not stuck there with a blank page.
ClientScript.RegisterClientScriptBlock(this.GetType(), "script01", "window.open('../Common/ViewDoc.aspx'); window.close();");

Open in new window

0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

726 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