Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to close the window after response?
    text
    copied!<p>I am using ASP.NET and C#. I am generating pdf and sending that on the pageload using </p> <pre><code>response.TransmitFile(file); </code></pre> <p>So after this I need to close this window.I try to write the dynamic script for closing, but that did not work.</p> <p>On button click i am using this code to open the window.</p> <pre><code>window.open("Export.aspx?JobNumbers=" + jobnums,'',"resizable=0,scrollbars=0,status=0,height=200,width=500"); </code></pre> <p>On pageload of export.cs I am creating the pdf using itextsharp.Then snding that using this.It is called on the buttonclick of the button that is clicked dynamically using </p> <pre><code> string script = "var btn = document.getElementById('" + Button1.ClientID + "');"; script += "btn.click();"; Page.ClientScript.RegisterStartupScript(this.GetType(), "Eport", script, true); </code></pre> <p>This is the onclick event of button.</p> <pre><code> protected void StartExport(object sender, EventArgs e) { response.Clear(); response.ContentType = "application/pdf"; response.AddHeader("content-disposition", "attachment;filename=" + Path.GetFileName(strFilePath)); response.TransmitFile(strFilePath); response.Flush(); } </code></pre> <p>After this i need to close this export.aspx window for that i used this. </p> <pre><code>Page.ClientScript.RegisterStartupScript(this.GetType(), "Export", "window.onfocus=function(){window.close();}", true); </code></pre> <p>And</p> <pre><code>HttpContext.Current.Response.Write("&lt;script&gt;window.onfocus=function(){window.close();}&lt;/script&gt;"); </code></pre> <p>But did not worked.</p> <p>Is it possible?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload