Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. Server header-asp.net problem

Server header-asp.net problem

Scheduled Pinned Locked Moved Web Development
databasehelpcsharpjavascriptasp-net
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    balu12345
    wrote on last edited by
    #1

    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.

    M 1 Reply Last reply
    0
    • B balu12345

      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.

      M Offline
      M Offline
      Martin Jarvis
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups