不能在UpdatePanel中下载文件 [英] Cannot Download file in UpdatePanel

查看:290
本文介绍了不能在UpdatePanel中下载文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面code ++工程,这让我下​​载一个Word文档.....

The below code works which allows me to download a Word document.....

   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 - 它不下载文件并没有错误产生?看完后,周围加我设置为启动创建Word文档文件中的按钮的控件ID值的触发器。我试过code的几种组合,但似乎没有任何工作。如何缩小这个下来任何帮助吗?我也调试并没有错误显示。香港专业教育学院检查了我的Downloads文件夹 - 什么都没有,尝试设置无缓存(Response.Cache.SetCacheability(HttpCacheability.NoCache)),并没有工作。当我删除的UpdatePanel然后一切似乎工作?

But as soon as i add an UpdatePanel - it doesnt download the file and no errors are generated? After reading around i added a trigger with the ControlID value set to the button that starts creating the Word doc file. I've tried several combinations of code but nothing seems to work. Any help on how to narrow this down? I've also debugged and no errors show. Ive checked my downloads folder - nothing there, tried setting no cache (Response.Cache.SetCacheability(HttpCacheability.NoCache)) and that didnt work. As soon as i remove the UpdatePanel then all seems to work?

   <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>
        ..

完全失去了在这一个。任何人都可以提出一个解决办法或如何解决这个问题呢?

Completely lost on this one. Could anyone suggest a workaround or how to tackle this problem?

推荐答案

在UpdatePanel不支持文件上传或下载。有吨支持Ajax的组件,在那里,将做到这一点,谷歌是你的朋友。

The UpdatePanel does not support file upload or download. There are tons of ajax-enabled components out there that will do this, Google is your friend.

编辑: -

一些例子: -

<一个href=\"http://forums.asp.net/t/1076322.aspx?How+to+create+a+flipcart+like+panel+for+showing+products+in+gridview\" rel=\"nofollow\">http://forums.asp.net/t/1076322.aspx?How+to+create+a+flipcart+like+panel+for+showing+products+in+gridview - 我喜欢这种方法,他注射使用JavaScript指向负责下载文件页面的iframe中。作品的UpdatePanel内

http://forums.asp.net/t/1076322.aspx?How+to+create+a+flipcart+like+panel+for+showing+products+in+gridview - I like this approach, he injects an IFrame using JavaScript that points to a page responsible for downloading the file. Works inside an UpdatePanel

http://encosia.com/ajax-file-downloads-and-iframes / - 类似的方法

这篇关于不能在UpdatePanel中下载文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆