server cannot set content type after http headers have been sent

Answered (Verified) This post has 1 verified answer | 2 Replies | 1 Follower Thread's RSS feed.

pioneer3001
Points 50
Replied On: Thu, May 7 2009 11:21 AM Reply

I'm trying a sample from Infragistics 3.0 (.NET 2.0) to export an UltraWebGrid to Excel formal.

But the bowser says "server cannot set content type after http headers have been sent".

code:

<%@ Page Language="C#" MasterPageFile="~/MasterPages/Head.master" AutoEventWireup="true" CodeFile="DBViewer.aspx.cs" Inherits="Viewers_DBViewer" %>
...
<asp:Content ID="contentHeader" ContentPlaceHolderID="HeaderPlaceHolder1" runat="server">
    ...//javascripts
</asp:Content>
<asp:Content ID="content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    ...
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            ...
            <asp:LinkButton ID="LinkButton1" runat="server" OnClick="LinkButton1_Click">Excel</asp:LinkButton>
            ...
            <obln:inhUltraWebGridDatabase id="UltraWebGrid1" runat="server" OnInitializeLayout="UltraWebGrid1_InitializeLayout" OnInitializeRow="UltraWebGrid1_InitializeRow" ImageDirectory="/ig_common/Images/">
                ...
            </obln:inhUltraWebGridDatabase>
        </ContentTemplate>
        <Triggers>
            <asp:AsyncPostBackTrigger ControlID="txtSearch" EventName="TextChanged"/>
        </Triggers>
    </asp:UpdatePanel>
    ...
    <igxl:UltraWebGridExcelExporter ID="UltraWebGridExcelExporter1" runat="server"
        OnInitializeRow="UltraWebGridExcelExporter1_InitializeRow" OnBeginExport="UltraWebGridExcelExporter1_BeginExport">
    </igxl:UltraWebGridExcelExporter>
</asp:Content>

What can I do in this case?

  • Post Points: 20

Verified Answer

pioneer3001
Points 50
Answered (Verified) Replied On: Thu, May 28 2009 9:25 AM Reply
Verified by pioneer3001

works4me:

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <Triggers>
                <asp:PostBackTrigger ControlID="LinkButton1" />
            </Triggers>

            <ContentTemplate>
            <table>
                <tbody>
                    <tr>
                        <td><asp:Label id="lblToolbar" runat="server"></asp:Label></td>
                        <td><asp:LinkButton ID="LinkButton1" runat="server" OnClick="LinkButton1_Click">Excel</asp:LinkButton></td>
                    </tr>
                </tbody>
            </table>
...

  • Post Points: 25

All Replies

Answered (Not Verified) Replied On: Thu, May 7 2009 3:01 PM Reply

You likely need to trigger a normal postback with whatever control (likely your LinkButton1 instance) that you're using to cause the export.

I provide additional details in the following forum thread:
http://forums.infragistics.com/forums/t/2001.aspx

Vince McDonald
Senior Developer Support Engineer, MCP

Need help? Find the various ways you can ask for help from Infragistics.

  • Post Points: 20
pioneer3001
Points 50
Answered (Verified) Replied On: Thu, May 28 2009 9:25 AM Reply
Verified by pioneer3001

works4me:

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <Triggers>
                <asp:PostBackTrigger ControlID="LinkButton1" />
            </Triggers>

            <ContentTemplate>
            <table>
                <tbody>
                    <tr>
                        <td><asp:Label id="lblToolbar" runat="server"></asp:Label></td>
                        <td><asp:LinkButton ID="LinkButton1" runat="server" OnClick="LinkButton1_Click">Excel</asp:LinkButton></td>
                    </tr>
                </tbody>
            </table>
...

  • Post Points: 25
Page 1 of 1 (3 items) | RSS