.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Page does not close after Response.BinaryWrite when opened in IE 6 sp 3

Posted By:      Posted Date: September 03, 2010    Points: 0   Category :.NET Framework
Hi all, I currently having problems in closing a page opened using IE 6 sp 3 after Response.BinaryWrite. All other versions of IE it closes fine. This page was opened using window.open. Below is a sample code of what i am trying to achieve: protected void Page_Load(object sender, EventArgs e) {            Response.Clear();  //Specify the document type.  Response.ContentType = "application/word";  //Specify how the document is sent to the browser.  Response.AddHeader("content-disposition", "attachment; filename=MyDasddsaocument.doc");  //Get data bytes from the file and send it to the response.  byte[] bytes = System.IO.File.ReadAllBytes(@"C:\\Temp\\in.doc");  Response.BinaryWrite(bytes);  Response.End();  Page.ClientScript.RegisterStartupScript(this.GetType(), "CloseMe", "window.close();", true); } I hope someone  can help me with this issue. Thank you in advance.

View Complete Post

More Related Resource Links

Check if a page is opened . IF opened, close the page.



I am generating a new report page by using the following code.

            ScriptManager.RegisterStartupScript(this, typeof(string), "openNewWindow", "window.open('../Report_Preview.aspx','ReportPreview','scrollbars=yes,resizable=yes,')", true);


 But, the above script is used in more than 20 parameter page which ultimately always open the same Report_preview.Aspx page.

What i want to check  while running the above script is "give a warning if the Report_preview.Aspx is already opened"


Any idea please!!!!!

Response.BinaryWrite help needed


Hi all

Im new to .NET and stuck now, so i hope anyone can help my with my problem.

I have a MS SQL database where i have stored some documents as Binary data. I cant figure out how to retrieve them and show/download them in my browser.

I found some guides online and have try to put something together.


private void Write()
 int id = 0;
 string strID = Request.QueryString["id"];
 int.TryParse(strID, out id);

 var db = new ModelDataContext();
 var doc = db.DocumentDatas.Where(x => x.ID == id).FirstOrDefault();

 byte[] byteArray = File.ReadAllBytes(doc);


How do i fill the byteArray with the data?

Thanks in advance :)


WebDev.WebServer.exe has encounted a problem and needs to close when trying to view page in browser


Hi, whenever I load an aspx page in vwde2008, I get the message in the subject of this post.  After I click Ok on that, I get a dialog box, Unable to Connect to the ASP.Net development center.  What can I do to troubleshoot?

I am using Windows XP SP3, vwde2008 with SP1, on a HP desktop.  Also using Office 2003 if that is relevant at all.

Thanks, Justin

Partial Views and Popups...After clicking on Close need to refresh the page....


Hi All,


I amusing the PopUp example as suggestedin the above forum link.....

But now i want to Refresh the page after clicking on Close(x) ...

So please help me....

Please advice...

Thanks in advance...



close pop up and refresh main page after popup close

I am working on a application in which When user clicks on a button  he should be redirected to facebook login page and after successfull login he shud be reirected back to my page. It all is working fine but now I have to do like thiswhen user click on the Button the the facebookbacklogin page shud be opened in popUp and when login is done successfully the popup window shud be closed and the main page shud be refreshed. anf If user is already login the popup window shud not be opened.How can i do this..How can I KNow that a popup window is opened and how can I close that??How to refresh when popup window is closed.I ahve to do like on this site..http://blippy.com/

Response.Redirect in C# for page to page parameter passing

Looking for examples of this, but can't find anything specific. I'm new to ASP.NET, and C# at the same time... so I'm struggling to get it right...  Thanks, Nick

This Page has been modified since you opened it on Sharepoint 2010

When I use Server.Transfer("page2.aspx") the page2.aspx get's succesfully loaded. But when you you use Server.Transfer("page1.aspx") to get back from that page2.aspx to the page1.aspx. I got the following error: This Page has been modified since you opened it. You must open the page again... The above scenario is working perfectly on MOSS2007. Has anybody got an idea why this is not working on Sharepoint 2010 server? Thx Kris Kris Buntinx

Detecting a page close using GetCallbackEventReference IIS6/IIS7 Issue

I have a popup page that when closed,  initiates a server side function that updates a DB table.  After looking at countless posts, I was able to use the following code (partial) to generate the callback when the window closes. The problem I'm having is that it works great on a server with IIS7, but the event doesn't fire on one with IIS6. Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load    If Not IsPostBack Then        Dim callBackReference As String = Page.ClientScript.GetCallbackEventReference(Me, "arg", "LogOutUser", "", True)        Dim logOutUserCallBackScript As String = "function LogOutUserCallBack(arg, context) { " & callBackReference & "; }"       Me.ClientScript.RegisterClientScriptBlock(Me.GetType(), "LogOutUserCallBack", logOutUserCallBackScript, True)    End If  End Sub      Public Function GetCallbackResult() As String Implements System.Web.UI.ICallbackEventHandler.GetCallbackResult               Return _callBackStatus    End Function     Public Sub RaiseCallbackEvent(ByVal eventA

Custom Edit form - close modal dialog and navigate to page

Hi, I created one custom edit form for my document library, replaced default save and cancel buttons with input buttons and added the form action to them. Then I set my page as default edit form. When I click edit button, my custom form opens in modal pop up. When I try to save the item by clicking new save button, item gets saved but pop remains as it is. Now, I want the modal pop up to get closed and navigate to page other than the parent page with some parameters after I click save button. How can I achieve this? Thanks!!

Problem with closing window in ie 6 sp 3 after download using Response.BinaryWrite

Hi all, I currently having problems in closing a page that launches a download (using Response.BinaryWrite) opened using IE 6 sp 3. All other versions of IE it closes fine. This page was opened using window.open. Below is a sample code of what i am trying to achieve: protected void Page_Load(object sender, EventArgs e) { Response.Clear(); //Specify the document type. Response.ContentType = "application/word"; //Specify how the document is sent to the browser. Response.AddHeader("content-disposition", "attachment; filename=MyDasddsaocument.doc"); //Get data bytes from the file and send it to the response. byte[] bytes = System.IO.File.ReadAllBytes(@"C:\\Temp\\in.doc"); Response.BinaryWrite(bytes); Response.End(); Page.ClientScript.RegisterStartupScript(this.GetType(), "CloseMe", "window.close();", true); } I hope someone can help me with this issue. Thank you in advance.

Refresh Parent Page List after Edit Item Modal Dialog Save/Close

I am calling the Edit Item URL (EditForm.aspx?ID=x&IsDlg=1) via javascript code to bring up the Edit Item Modal Dialog. This works fine and dandy. But what callbackfunction should I invoke after the Save so that the parent list is refreshed? Is there a better way to do it than call reload on the entire parent frame? It almost looks like there should be a way to refresh just the list. Any help appreciated. Thanks, Jake.

How to set Page title for Response.ContentType = "image/jpeg"

Hi , how can i set Title for a page with Response.ContentType = "image/jpeg" ? thanks, Naresh

close aspx page after executing code behind


I am working in vs 2008, C#.

Load event in my aspx page is having a set of database operations .So after completing those operations i want to close the aspx page.

for that i am calling 

window.close() methond onload event of the body. Its closing the aspx page but it is showing the confirmation message before closing the page.

I dont want to show that message box.

How can i claose an aspx page without showing any message?.

Pls help me



How to Trap a "Page Back" or "Page Close" or "Tab Close" Event


 VWD 2008 Express.  Visual Basic.

I have seen pages on the net that when you try to navigate away, they pop up a message asking whether you really want to navigate away.  How can I accomplish this to detect someone hitting the "page back" arrow in a browser or the "x" that closes a browser page or when someone tries to close a browser tab?  Thanks for the help.

Can i not show Response.write on a page?



I'm doing something for  paypal.

So i have my values for paypal PDT like this:

 Public Function PayPalPostForm() As String
        Dim s = Request.QueryString("tx")
        Dim PostUrl As String = "https://www.sandbox.paypal.com/cgi-bin/webscr"
        Dim Cmd As String = "_notify-synch"
        Dim Method As String = "post"
        Dim submitvalue As String = "PDT"
        Dim tx As String = s
        'my sandbox merchand identity token 
        Dim at As String = "J9Z11-6776aOBoIOMqiWDEFGUmonSwyqM2QiGriz7Rn-f7Y_z0KEQkUvLSa"

        'Create the Form to write to the page with PayPal parameters      
        Dim ppForm As New StringBuilder()
        ppForm.AppendFormat("<Form name='frmPP' id='frmPP' action='{0}' method='{1}'>", PostUrl, Method)        
        ppForm.AppendFormat("<input type='hidden' name='cmd' value='{0}'>", Cmd)
        ppForm.AppendFormat("<input type='hidden' name='tx' value='{0}'>", tx)
        Return ppForm.ToString()
    End Function

and then i will send the form to paypal and ge

How to print pdf using shellExecute and close the adobe reader which is opened while printing?



I'm trying to print pdf file using shellExecute. Here is my code.

#region " CONSTANTS "
    private const int SW_SHOWNORMAL=2;
      #region " API "
      public static extern IntPtr ShellExecute(IntPtr hWnd, string lpOperation, string lpFile, string lpParameters, string lpDirectory, int nShowCmd);
      #region " PUBLIC MEMBERS "
      public bool PrintPDF(string FilePath)
        if (System.IO.File.Exists(FilePath))
          if (ShellExecute((IntPtr)(1), "Print", FilePath, "", Directory.GetDirectoryRoot(FilePath), SW_SHOWNORMAL).ToInt32() <= 32)
            return false;

            return true;
          return false;

      private void button1_Click(object sender, RoutedEventArgs e)

I get the selected pdf file printed. But, it leaves blank Adobe Reader window open. I want to close the adobe reader window from the program itself. Is there any way not to open the adobe reader window?

If somebody has any idea about this,

Javascript to identify whether a page is opened in a popup


Hey every one.


I have an AllItems.aspx page in my Sharepoint list. Requirement is to close the page in the page load if it is opened in a popup window.

If it is opened not in the popup window, then we don not want to close it.

I am looking for a javascript to do this. I want a javascript to be placed in the content editor web part (CEWP) present in my AllItems.aspx.

Any one knows how to do this ?

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend