ASP.Net Ajax AsyncFileUpload 控件未触发服务器端 OnUploadCompleted 事件
我正在编写一个应用程序,要求用户将文件上传到服务器计算机。所有用户与用户的交互都是通过 JQuery UI 模式弹出窗口完成的。我创建了一个测试页面来查看 AsyncFileUpload 控件是否正常工作,并且一切正常。我将 AsyncFileUpload 添加到我需要的 Web 表单中,在模式弹出窗口中,但由于某种原因,服务器端事件从未被触发。此页面与测试页面的唯一区别是,我通过查询字符串发送一个变量,在页面初始加载时,我将该变量存储在视图状态中(因此在将来的回发中不需要它)。有什么想法吗?
谢谢
I am writing an application that requires a user to upload files to the server machine. All user interaction with the user is done via JQuery UI modal popups. I created a test page to see that the AsyncFileUpload control works, and everything works fine on it. I added the AsyncFileUpload to the webform that I need it on, in a modal popup, but for some reason the server side event is never fired. The only difference on this page from the test page is that I send a variable through on the querystring which I, on initial load of the page, store in the viewstate (so it isn't required on future postbacks). Any ideas?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
处理 AsyncFileUpload 控件的事件时,将任何数据存储在会话状态而不是视图状态中。
When dealing with AsyncFileUpload Control's Event, store any data in Session state instead of viewstate.
当您使用 AsyncFileUpload 时,您必须在放置在页面或 MasterPage 中的“form”标记中设置正确的参数:
如果您没有设置正确的 enctype 和方法UploadedComplete 将永远不会触发,并且您将无法获取 FileUpload.FileBytes,因为 FileUpload.HasFile 仅在 UploadedComplete 执行期间返回 true。
我想您没有在模式弹出窗口中设置正确的 enctype。
此外,之前版本的 AsyncFileUpload 无法在 Chrome 上运行。实际版本(4.1.50731.0)解决了该问题。
When you use AsyncFileUpload you must set the right params in the "form" tag, that is placed in your Page or MasterPage:
If you don't set the right enctype and method UploadedComplete will never fire, and you won't be able to get FileUpload.FileBytes since FileUpload.HasFile returns true only during UploadedComplete execution.
I suppose that you didn't set the correct enctype on your modal popup.
Besides, prevoius versions of AsyncFileUpload didn't work on Chrome. Actual version (4.1.50731.0) solved the problem.