I am using Master p开发者_开发技巧age for my page. in this page i have gridview inside updatepanel . I want to export that GridView to Excel. while doing this i am getting error Like this
Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled. Details: Error parsing near '
Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled.
Details: Error parsing near '
eventhough i added following :
EnableEventValidation ="false"
<asp:AsyncPostBackTrigger ControlID="btn_export" EventName="Click" />
My markup:
<%@ Page Language="C#" MasterPageFile="~/C2SFAMaster.master" AutoEventWireup="false" EnableEventValidation ="false" CodeFile="GDNReport.aspx.cs" Inherits="GDNReport" Title="Untitled Page" %>
<%@ Register Assembly="AjaxControlToolkit, Version=1.0.11119.21057, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<table>
<tr>
<td>
<TABLE class="TableBgColor">
<TBODY>
<TR class="TableHDColor"><TD colSpan=6>Sample Dispatch Note Report</TD></TR>
<TR>
<td>Select Fs</td>
<td>
<asp:DropDownList ID="cmb_fs" runat="server" Width="200px" AppendDataBoundItems="True" SkinID="DropDowns">
<asp:ListItem Value="-99">--------------------ALL------------------</asp:ListItem>
</asp:DropDownList></td>
<td>DateFrom</td>
<td>
<asp:TextBox id="txt_frdate" runat="server" SkinID="Textboxs" />
<cc1:CalendarExtender id="CalendarExtender1" runat="server" TargetControlID="txt_frdate" Format="d/MM/yyyy" />
</td>
<td>DateTo</td>
<td>
<asp:TextBox id="txt_todate" runat="server" SkinID="Textboxs" />
<cc1:CalendarExtender id="CalendarExtender2" runat="server" TargetControlID="txt_todate" Format="d/MM/yyyy" />
</td>
</TR></TABLE>
</td>
</tr>
<tr>
<td align ="center" >
<asp:Button ID="btn_view" runat="server" Text="View" OnClick="btn_view_Click" OnClientClick="return viewcheck();" CssClass="Button" />
</td>
</tr>
<tr>
<td align="center">
<asp:UpdatePanel id="swpnl" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:GridView ID="gdview" runat="server" OnRowDataBound="gdview_RowDataBound" OnRowCreated="gdview_RowCreated" style="position: relative" />
</ContentTemplate>
<triggers>
<asp:AsyncPostBackTrigger ControlID="btn_view" EventName="Click"> </asp:AsyncPostBackTrigger>
<asp:AsyncPostBackTrigger ControlID="btn_export" EventName="Click" />
</triggers>
</asp:UpdatePanel>
<asp:Button ID="btn_export" runat="server" CssClass="Button" OnClick="btn_export_Click" Style="position: relative" Text="Export To Excel" />
</td></tr>
</table>
</asp:Content>
I am guessing that in the updatepanel
request you are trying to write the data to the response stream
.
I don't think this will work very well, as it will be trying to add a write response
to the update panel handler
which won't like you trying to write a file to it, not that I have ever tried so it may work.
You are better off doing this with a normal postback
; or if it must be async
send them a redirect
to another handler that writes the file
精彩评论