Server header-asp.net problem
-
Hi All, In my Webpage i have a Button control. On the button Click i have following functionalities **1.**To show the "progress bar" Icon during retrieving data from Sqlserver Database.. **2.**After retrieving a Data from DB a csv report will be generated. For Point 1--the below is the code i have used Code snippet for busy Icon: ============================ Response.Write("<div ID='mydiv' STYLE='position:absolute;z-index:5000;top ;left ;width:100%;height:100%;'><table cellspacing='0' cellpadding='0' border='0' align='center'><tr><td class='copy' align='right' height='260'><img src='./processingimage.gif' width='0' align='absmiddle'></td></tr><tr><td class='copyblack' style='font-family:arial;font-size:14px' align='center'><img src='./processingimage.gif' border='0' align='absmiddle'><br><br>" + strBusyMessage + "<br>" + strReportCreteria + "</td></tr></table>") Response.Write(" ") Response.Write("</div>") Response.Write("<script> var mydiv = document.getElementById('mydiv');</script>") Response.Write("<script language=javascript>") Response.Write("function StartShowWait(){mydiv.style.visibility ='visible';}") Response.Write("function HideWait(){mydiv.style.visibility = 'hidden';}") Response.Write("StartShowWait();</script>") 'Page.Session.Add("SessionID", Session.SessionID) Response.Flush() ================================= For point 2: please see the below code snippet Code snippet to generate CSV report. ================================================== Response.AddHeader("Content-Disposition", "attachment; filename=" + CSVName) Response.ContentType = "application/csv" Response.Write(CSVContent) Response.Flush() Response.Close() ===================================================== when coming to above mention code line(bold one in above snippet) i am getting the below error "Server cannot append header after HTTP headers have been sent" Please help me in resolving the above error.
-
Hi All, In my Webpage i have a Button control. On the button Click i have following functionalities **1.**To show the "progress bar" Icon during retrieving data from Sqlserver Database.. **2.**After retrieving a Data from DB a csv report will be generated. For Point 1--the below is the code i have used Code snippet for busy Icon: ============================ Response.Write("<div ID='mydiv' STYLE='position:absolute;z-index:5000;top ;left ;width:100%;height:100%;'><table cellspacing='0' cellpadding='0' border='0' align='center'><tr><td class='copy' align='right' height='260'><img src='./processingimage.gif' width='0' align='absmiddle'></td></tr><tr><td class='copyblack' style='font-family:arial;font-size:14px' align='center'><img src='./processingimage.gif' border='0' align='absmiddle'><br><br>" + strBusyMessage + "<br>" + strReportCreteria + "</td></tr></table>") Response.Write(" ") Response.Write("</div>") Response.Write("<script> var mydiv = document.getElementById('mydiv');</script>") Response.Write("<script language=javascript>") Response.Write("function StartShowWait(){mydiv.style.visibility ='visible';}") Response.Write("function HideWait(){mydiv.style.visibility = 'hidden';}") Response.Write("StartShowWait();</script>") 'Page.Session.Add("SessionID", Session.SessionID) Response.Flush() ================================= For point 2: please see the below code snippet Code snippet to generate CSV report. ================================================== Response.AddHeader("Content-Disposition", "attachment; filename=" + CSVName) Response.ContentType = "application/csv" Response.Write(CSVContent) Response.Flush() Response.Close() ===================================================== when coming to above mention code line(bold one in above snippet) i am getting the below error "Server cannot append header after HTTP headers have been sent" Please help me in resolving the above error.
Hi, This approach won't work as calling Response.Write will force the Response Headers to be sent to the client. To get the AJAX style loading screen I think you're trying to get, you should include the markup for the busy icon on the first page and call the StartShowWait() method on the button click. The CSV will then generate as a normal ASP.Net request as you'd expect. Regards, Martin