生成的下载按钮单击文件 - 不破坏其它按钮 [英] Generate a file for download on button click - without breaking other buttons

查看:171
本文介绍了生成的下载按钮单击文件 - 不破坏其它按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想提供一个选项,下载报告(CSV格式),允许用户选择特定的日期范围。 (我也有以显示在GridView页面上的相同的信息的一个选项)。我可以通过使用Response.Clear(),设置的ContentType和内容处置,利用的Response.Write()这样做就好了,然后到Response.End(),喜欢的这个博客,以及其他许多。

I'm trying to provide an option to download a report (in csv format), allowing the user to select a specific date range. (I also have an option to display the same information in a GridView on the page). I can do this just fine by using Response.Clear(), setting the ContentType and content-disposition, using Response.Write(), and then Response.End(), like this blog, and many others.

但是,这样做之后,按钮似乎已不再被回发到服务器。我可以更新我在GridView报告然而很多次我都喜欢,但只要我出口既不按钮将响应(即不再产生服务器端事件)。我怎样才能得到一个文件,并保存按钮respoding?这是一个SharePoint应用程序页面上,所以有东西在母版页事情一大堆。

However, after doing this, the buttons no longer seem to be posting back to the server. I can update my report in the GridView however many times I like, but as soon as I export neither button will respond (i.e. no further server side events are generated). How can I get a file and keep the buttons respoding? This is on a SharePoint application page, so there's a bunch of stuff going on in a Master page.

推荐答案

和我找到答案<一个href=\"http://stackoverflow.com/questions/7749393/no-more-post-back-after-file-download-in-sharepoint\">in这个问题

的SharePoint注册了一个名为_spFormOnSubmitCalled变量一旦它被设置为true,将prevent的回传。我已经添加了的OnClientClick到我的按钮,在短暂的延迟后,将其设置回为false,在斯特凡的答案。

SharePoint registers a variable called "_spFormOnSubmitCalled" which will prevent any postbacks once it is set to true. I've added an OnClientClick to my button to set it back to false after a short delay, as in Stefan's answer.

这篇关于生成的下载按钮单击文件 - 不破坏其它按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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