Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
330
WebAsyncRefresh Panel - LiteralControl
posted
I have a problem using below line. I have a web async panel in my page. I want to open one page which was DownloadFile.aspx for that I used below code. In my system It was working fine. But when I installed my project into Production environment it was not working. In DownloadFile.aspx page load event have Response.Write() and Response.clear() these statements.  Whether can I use Response object in web async panel or not? Can you give me brief idea?  wrpWorkSheet.Controls.Add(new LiteralControl("<script language='javascript'>window.open('DownloadFile.aspx', '', '');</script>")); In DownloadFile.aspx – Page load event Response.Clear();            Response.Buffer = true;            Response.ContentType = "application/pdf";            string file = GetStoreValue(Constants.PreviewFileName).ToString();            string displayFileName = GetStoreValue(Constants.PreviewDisplayFileName).ToString();            SetStoreValue(Constants.PreviewFileName, null);            SetStoreValue(Constants.PreviewDisplayFileName, null);            FileStream LimitedPowerofAttorneyforUSBankStream = new FileStream(file, FileMode.Open, FileAccess.Read);            byte[ LimitedPowerofAttorneyforUSBankBuffer = new byte[LimitedPowerofAttorneyforUSBankStream.Length];            LimitedPowerofAttorneyforUSBankStream.Read(LimitedPowerofAttorneyforUSBankBuffer, 0, (int)LimitedPowerofAttorneyforUSBankStream.Length - 1);            Response.AddHeader("content-disposition", "attachment;filename=" + displayFileName);            Response.BinaryWrite(LimitedPowerofAttorneyforUSBankBuffer);            LimitedPowerofAttorneyforUSBankStream.Close();            File.Delete(file);            Response.End();            Response.Flush();

            Response.Close();

Parents
No Data
Reply
  • 475
    posted

     Hi Sudheer

       I have a very similar problem. I have create a page with a warp from this i trigger a link to a new windows that dowmloads a file using the exportexcel or Response.BinaryWrite.

       Everything work really nice in my local computer using IE7 and visual studio. When I deploy the application to the server it only work fine with IE6 but not with IE7 .IE7 closes the new window without showing any error message.

      Is infragistic not compatible with IE7 for exporting grids to excel and pdf????? Have you some answer

     Have you found a reason for that???? Please help.. I need that as soon as possible. Thanks Sudheer. Below my code:

            if (contentReportDs != null)
            {
                uwgExportReport.DataSource = contentReportDs;
                switch (Convert.ToInt32(Enum.Parse(outputFormatReceived, outputFormat)))
                {
                    case 0: // CSV file
                        if (this.loadPlugin(outputFormat, ref aMessage))
                        {
                            Panel csvPanel = ((Panel)this.plugin.generate(this.wpDownloadReport, contentReportDs));
                            Label csvLabel = new Label();
                            for(int i=0; i<csvPanel.Controls.Count;i++)
                                if (csvPanel.Controls[i] is Label)
                                    csvLabel = csvPanel.Controls[i] as Label;

                            string csvContentToShow = csvLabel.Text;
                            csvContentToShow = csvContentToShow.Replace("<br />", "" + '\n');
                            byte[ bytFile = System.Text.Encoding.UTF8.GetBytes(csvContentToShow);
                            Response.Clear();
                            Response.Buffer = true;
                            Response.ContentType = "application/vnd.ms-excel";
                            Response.AddHeader("content-disposition", "attachment;filename=" + fileName);

                            Response.Charset = "";
                            Response.Cache.SetCacheability(HttpCacheability.NoCache);

                            // If you write,
                            // Response.Write(bytFile1);
                            // then you will get only 13 byte in bytFile.
                            Response.BinaryWrite(bytFile);

                            Response.End();
                           
                        }
                        break;
                    case 2: // XLS

                        uwgExportReport.DataBind();
                        uwgReportExpXls.ExcelStartRow = reportParamValueList.Count + 6;
                        this.uwgReportExpXls.DownloadName = fileName + ".XLS";
                        this.uwgReportExpXls.Export(uwgExportReport);
                        break;
                    case 3://CSV
                        if (this.loadPlugin(outputFormat, ref aMessage))
                        {
                            Panel csvPanel = ((Panel)this.plugin.generate(this.wpDownloadReport, contentReportDs));
                            Label csvLabel = new Label();
                            for (int i = 0; i < csvPanel.Controls.Count; i++)
                                if (csvPanel.Controls[i] is Label)
                                    csvLabel = csvPanel.Controls[i] as Label;

                            string csvContentToShow = csvLabel.Text;
                            csvContentToShow = csvContentToShow.Replace("<br />", "" + '\n');
                            csvContentToShow = csvContentToShow.Replace("&lt;", "" + '<');
                            csvContentToShow = csvContentToShow.Replace("&gt;", "" + '>');
                            byte[ bytFile = System.Text.Encoding.UTF8.GetBytes(csvContentToShow);
                            Response.Clear();
                            Response.Buffer = true;
                            Response.ContentType = "text/xml";
                            Response.AddHeader("content-disposition", "attachment;filename=" + fileName + ".xml");

                            Response.Charset = "";
                            Response.Cache.SetCacheability(HttpCacheability.NoCache);
                            Response.BinaryWrite(bytFile);

                            Response.End();
                        }
                        break;
                    case 4://PDF
                        uwgExportReport.DataBind();
                        this.uwgReportExpDocument.Format = Infragistics.Documents.Report.FileFormat.PDF;
                        this.uwgReportExpDocument.DownloadName = fileName + ".pdf";
                        // trigger export
                        this.uwgReportExpDocument.Export(uwgExportReport);
                        break;
                    case 5://XPS
                        uwgExportReport.DataBind();
                        this.uwgReportExpDocument.Format = Infragistics.Documents.Report.FileFormat.XPS;
                        this.uwgReportExpDocument.DownloadName = fileName + ".xps";
                        // trigger export
                        this.uwgReportExpDocument.Export(uwgExportReport);
                        break;
                    case 6://NOtepad -- Text

                       uwgExportReport.DataBind();
                        this.uwgReportExpDocument.Format = Infragistics.Documents.Report.FileFormat.PlainText;
                        this.uwgReportExpDocument.DownloadName = fileName + ".txt";
                        // trigger export
                        this.uwgReportExpDocument.Export(uwgExportReport);
                        break;
                    default:
                        //this.wpDownloadReport.Controls.Clear();
                        if (this.loadPlugin(outputFormat.Replace('_',' '), ref aMessage))
                        {
                           this.wpDownloadReport.Controls.Add(this.plugin.generate(this.wpDownloadReport, contentReportDs));
                            this.wpDownloadReport.Visible = true;
                        }
                        else
                        {
                            this.tbAlertMessage.Text = aMessage;
                        }
                       
                        break;
                }
Children