Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error: Server cannot set content type after HTTP headers have been set

Status
Not open for further replies.

ChasBoots

MIS
Jul 23, 2002
24
US
Greetings.... All attempts to find a solution have come up empty thus far. I hope someone here has an answer or suggestion. On my web page, I have an Export button to send the output to an Excel workbook. The code is very similar to what others have posted in other threads:

Code:
    Private Sub btnExport_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExport.Click
        Dim s, f, g, h, w, o, pSql, pFarm, pAppName As String

        s = lbSql.Items.Item(0).Value
        f = lbSql.Items.Item(1).Value
        w = lbSql.Items.Item(2).Value
        g = lbSql.Items.Item(3).Value
        h = lbSql.Items.Item(4).Value
        o = lbSql.Items.Item(5).Value
        pSql = s & f & w & g & h & o
        pFarm = farmselect()
        pAppName = dd_AppName.SelectedItem.ToString
        Response.Redirect("datatoexcel.aspx?psql=" & pSql.ToString & "&pfarm=" & pFarm.ToString & "&pappname=" & pAppName)
    End Sub

Until recently, the export worked perfectly. I have isolated the problem to another block of code I added which displays a small pop-window when rolling over an image button. This code works as I had hoped but appears to have "broken" my export function.

Code:
    Private Sub SetRepIdx()
        Dim RepNameHTML, RepHelpHTML As String
        Dim divHTML, divHTMLhdr, divHTMLftr As String

        divHTMLhdr = "<div style='background:gold; FONT-FAMILY:Verdana; FONT-WEIGHT: normal;'>"
        divHTMLhdr &= "<P align='center'>"
        divHTMLftr = "<HR style='HEIGHT: 3px; BACKGROUND-COLOR: black'>"

        Select Case dd_RptList.SelectedIndex
            Case 0
                .
                .
                .
                RepNameHTML = "Some string"
                RepHelpHTML = "Some other string"
                .
                .
             Case n
        End Select

        divHTML = divHTMLhdr & RepNameHTML & divHTMLftr & RepHelpHTML & "</div>"
        Response.Write("<div id='Rep_Index' STYLE='VISIBILITY:hidden; FONT-SIZE: 11pt; COLOR:red; FONT-FAMILY:Verdana; POSITION:absolute;'>")
        Response.Write(divHTML)
        Response.Write("</div>")
        Response.Flush()
    End Sub

As I stated above, the export function now aborts while the popup messages appear. If I remove the call to SetRepIdx, the export will work.

I have also tried replacing the Response.Redirect with Server.Transfer (including URL encoding where appropriate) but get the same error message:

"Server cannot set content type after HTTP headers have been set"

Lastly, I have tried adding Response.Clear and Response.ClearContents (as has been suggested from other sources) to no avail. Any insight as to how I can resolve this without sacrificing one function or the other would be appreciated. Thanks.

Chas
 
Response.Write" = urgh! This may be interfering with you page as it could be writing it out anywhere (have a look at the View Source to see what I mean). My guess is that the page definately won't validate with this usage.

Ignoring what you've done so far, what exactly do you want to do?


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Let's see if I can describe what I want to do without getting too convoluted....

My form has a dropdownlist server control (dd_RptList) which displays a static list of reports that can be executed. The image button (img_Question)is within a <span> element (span_Question). When rolling over img_Question, a small popup window appears to display a brief description of the report selected in dd_RptList. The mouseover event for img_Question (which is added to the control in another procedure) triggers the function dispPopUp() which is defined as follows:

Code:
		function dispPopUp() 
			{ 
			var oPopup = window.createPopup(); 
			var oPopupBody = oPopup.document.body; 
			
			oPopupBody.innerHTML = Rep_Index.innerHTML; 
			oPopup.show(20, 40, 400, 120, event.srcElement); 
			}

I absolutely need to maintain "something" in terms of a popup window to describe the selected item in dd_RptList. I am not opposed to trying different methods to accomplish that task if it means correcting the Export function. Unfortunately, I suppose this is a case where I want my cake and eat it, too...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top