asp.net – 无法在UpdatePanel中下载文件
下面的代码可以让我下载一个Word文档….. Try Response.BufferOutput = True HttpContext.Current.Response.Clear() HttpContext.Current.Response.Charset = "" HttpContext.Current.Response.ContentType = "application/msword" HttpContext.Current.Response.AddHeader("Content-Disposition","inline;filename=myfile.doc") HttpContext.Current.Response.Write(s) 'HttpContext.Current.Response.End() HttpContext.Current.ApplicationInstance.CompleteRequest() HttpContext.Current.Response.Flush() Catch ex As Exception Response.Write(ex.Message) End Try 但是,只要我添加一个UpdatePanel – 它没有下载文件,没有生成错误?阅读后,我添加了一个触发器,其ControlID值设置为开始创建Word doc文件的按钮.我已经尝试了几种代码组合,但似乎没有任何效果.有关如何缩小范围的任何帮助?我也调试了,没有错误显示.我检查了我的下载文件夹 – 没有任何东西,尝试设置无缓存(Response.Cache.SetCacheability(HttpCacheability.NoCache)),并没有工作.一旦我删除UpdatePanel,那么一切似乎都有效? <asp:UpdateProgress ID="ProgressUpdate" AssociatedUpdatePanelID="UpdatePanel1" runat="server"> <ProgressTemplate> <img alt="progress" src="../images/loading.gif" /> </ProgressTemplate> </asp:UpdateProgress> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <Triggers> <asp:PostBackTrigger ControlID="buttonDownloadFile" /> </Triggers> <ContentTemplate> .. 完全失去了这一个.任何人都可以建议解决方法或如何解决这个问题? 解决方法UpdatePanel不支持文件上载或下载.有很多支持ajax的组件可以做到这一点,谷歌是你的朋友.编辑: – 一些例子: – http://forums.asp.net/t/1076322.aspx?How+to+create+a+flipcart+like+panel+for+showing+products+in+gridview – 我喜欢这种方法,他使用JavaScript注入IFrame,指向负责下载文件的页面.在UpdatePanel内部工作 http://encosia.com/ajax-file-downloads-and-iframes/ – 类似的方法 (编辑:鲜蔬坊站长网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
- 显示下载进度条的下载文件代码
- asp.net-core – ASP.Net 5类库中的EntityFramework命令?
- 如何在ASP.NET页面上使用框架?
- asp.net – 在fileupload中选择立即调用C#函数文件
- asp.net-mvc – 从Api控制器内生成绝对的url to action
- ASP.NET Webdeploy失败;项目中不存在AddScheduledJob
- .Net Web开发技术栈
- asp.net – Ajax上的Identity Server 3 – 401而不是302
- asp.net – Tridion分析和个性化错误:用户不能为空.请确保
- asp.net-mvc – 程序集使用System.Web.Http 5.1,它比引用的