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:
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.
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
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