Sys.WebForms.PageRequestManagerParserErrorException

时间:2016-08-18 08:49:40

标签: c# asp.net telerik

test.ascx.cs文件(Web用户控件)上的以下代码

protected void lnkOrderDetail_Command(object sender, CommandEventArgs e)
    {
      Telerik.Web.UI.GridDataItem item = gvAllDocuments.Items[int.Parse(e.CommandArgument.ToString())];
                string FileName = item["documentFileName"].Text;
                string PathString = @"C:\Documents\";
                string SubPath = PathString + Utils.GetUserName() + "\\" + FileName;
                FileInfo FileInfo1 = new FileInfo(SubPath);

                Response.ClearContent();
                Response.AppendHeader("Content-Disposition", "attachment; filename=" + FileName + "");
                Response.ContentType = "text/HTML";
                Response.AddHeader("Content-Length", FileInfo1.Length.ToString());                   

                Response.TransmitFile(SubPath);
                Response.End();
}

<asp:UpdatePanel ID="UpdatePanelDocuments" runat="server" UpdateMode="Conditional">
    <ContentTemplate>
        <asp:Button ID="ViewDocumentsButton" runat="server" Text="View/Upload Documents" OnClick="ViewDocumentsButton_Click" />

        <asp:PlaceHolder ID="UploadPlaceHolder" runat="server" Visible="false">

            <hr />         
            <br />
            <asp:Label Text="Document Type  :" runat="server" ID="DocuemntLabel"></asp:Label>&nbsp;

            <br />          
            <asp:Label Text="File :" runat="server" ID="FileLabel"></asp:Label>&nbsp;&nbsp;&nbsp;
           <asp:FileUpload ID="FileUpload1" runat="server" />
            <asp:RegularExpressionValidator ID="uplValidator" runat="server" ControlToValidate="FileUpload1"
                ErrorMessage=".png, jpg & pdf formats are allowed"
                ValidationExpression="(.+\.([Pp][Nn][Gg])|.+\.([Jj][Pp][Gg])|.+\.([Pp][Dd][Ff]))"></asp:RegularExpressionValidator>
            <asp:CustomValidator ID="customValidatorUpload" runat="server" ErrorMessage="" ControlToValidate="FileUpload1" ClientValidationFunction="setUploadButtonState();" />
            <br />

            <asp:Button ID="btnUpload" runat="server" Text="Upload file" OnClick="Upload" Enabled="false" />&nbsp;&nbsp;
</asp:Label>
            <br />
            <br />                

            <telerik:RadGrid ID="gvAllDocuments" runat="server" AutoGenerateColumns="false"
                AllowFilteringByColumn="true" RegisterWithScriptManager="true"
                AllowPaging="true" PageSize="10">
                <GroupingSettings CaseSensitive="false" />
                <MasterTableView CommandItemSettings-ShowExportToExcelButton="false" CommandItemSettings-ShowRefreshButton="false" CommandItemSettings-ShowAddNewRecordButton="false" CommandItemDisplay="Top">
                    <Columns>                  

                        <telerik:GridBoundColumn DataField="fileType" HeaderText="File Type" Visible="false"></telerik:GridBoundColumn>
                        <telerik:GridTemplateColumn>
                            <ItemTemplate>
                                <asp:Button ID="lnkOrderDetail" runat="server" Text="View" CommandArgument='<%#Container.ItemIndex%>' OnCommand="lnkOrderDetail_Command"></asp:Button>
                            </ItemTemplate>
                        </telerik:GridTemplateColumn>
                    </Columns>
                </MasterTableView>
                <ClientSettings>
                    <Resizing AllowResizeToFit="true" />
                </ClientSettings>
            </telerik:RadGrid>
        </asp:PlaceHolder>
    </ContentTemplate>
     <Triggers>
                <asp:PostBackTrigger ControlID="btnUpload" />
            </Triggers>    

</asp:UpdatePanel>

TransmitFile没有做任何事情?! 我在web-console上收到以下错误

  

错误:Sys.WebForms.PageRequestManagerParserErrorException:The   无法解析从服务器收到的消息。常见原因   对于此错误,是通过调用修改响应的时间   Response.Write(),响应过滤器,HttpModules或服务器跟踪是   启用。

     

详细信息:解析&#39;����N\ Exif

附近时出错

1 个答案:

答案 0 :(得分:0)

这对我来说很好,因为按钮包含 Telerik 网格
我添加以下内容:

<Triggers>
             <asp:PostBackTrigger ControlID="gvAllDocuments" />
  </Triggers>