未被捕獲的Sys.WebForms.PageRequestManagerParserErrorException:Sys.WebForms.PageRequestManagerParserErrorException:無法解析從服務器收到的消息。無法下載VB中的文件ASP.NET
當我單擊下載按鈕時出現此錯誤。
ASPX.cs
<asp:UpdatePanel runat="server" ID="UpdatePanelContent" UpdateMode="Conditional">
<Triggers>
<asp:PostBackTrigger ControlID="btnupload" />
</Triggers>
<ContentTemplate>
<asp:FileUpload runat="server" ID="FileUpload1" value="Upload" />
<asp:Button ID="btnupload" runat="server" OnClick="button1_click" Text="Upload"></asp:Button>
<%-- <asp:LinkButton ID="OnLnkDownload" runat="server" OnClick="OnLnkDownload_Click" Font-Underline="False">Download</asp:LinkButton>--%>
</ContentTemplate>
</asp:UpdatePanel>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false" EmptyDataText="No files uploaded">
<Columns>
<asp:BoundField DataField="Text" HeaderText="File Name" />
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="lnkDownload" Text="Download" CommandArgument='<%# Eval("Value") %>' runat="server" OnClick="DownloadFile"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="lnkDelete" Text="Delete" CommandArgument='<%# Eval("Value") %>' runat="server" OnClick="DeleteFile" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
代碼
Protected Sub DownloadFile(ByVal sender As Object, ByVal e As EventArgs)
Dim filePath As String = CType(sender, LinkButton).CommandArgument
Response.ContentType = ContentType
Response.AppendHeader("Content-Disposition", ("attachment; filename=" + Path.GetFileName(filePath)))
Response.WriteFile(filePath)
Response.End()
End Sub
背後請幫助在那裏我得到了?
你可以摺疊你的答案,並告訴我,我該如何做到這一點? –
現在更清楚了嗎? – Stilgar