Parthap
asked on
How do i close pop up window after opening a document from a link in popup?
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.
ASKER
no window.close is not working.
on click event i set some value, and call Server.Execute() as shown below
Session["DocRef"] = Request.QueryString["DocRe fNo"].ToSt ring();
Session["DocName"] = Request.QueryString["DocNa me"].ToStr ing(); ;
Session["DocExt"] = Request.QueryString["DocEx t"].ToStri ng(); ;
Session["DocSec"] = Request.QueryString["DocSe c"].ToStri ng(); ;
Session["DocVerNo"] = Request.QueryString["DocVe r"].ToStri ng(); ;
Server.Execute("../Common/ ViewDoc.as px");
Response.Write("<script>wi ndow.close ();</scrip t>");
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("conten t-disposit ion", "attachment;filename=" + Session["DocName"].ToStrin g());
Byte[] bytBinaryReadContent = Convert.FromBase64String(s trcontent) ;
Response.BinaryWrite(bytBi naryReadCo ntent);
Response.Flush();
Response.Close();
on click event i set some value, and call Server.Execute() as shown below
Session["DocRef"] = Request.QueryString["DocRe
Session["DocName"] = Request.QueryString["DocNa
Session["DocExt"] = Request.QueryString["DocEx
Session["DocSec"] = Request.QueryString["DocSe
Session["DocVerNo"] = Request.QueryString["DocVe
Server.Execute("../Common/
Response.Write("<script>wi
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("conten
Byte[] bytBinaryReadContent = Convert.FromBase64String(s
Response.BinaryWrite(bytBi
Response.Flush();
Response.Close();
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();
ASKER
Hi,
//ClientScript.RegisterCli entScriptB lock(this. GetType(), "script01", "window.open('../Common/Vi ewDoc.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.
//ClientScript.RegisterCli
I tried this also, but it can not open document. After click on link page is blank out and stuck there only.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
is window.close() not working?