AJAX updatepanel 中的文件上传没有完整的回发

发布于 2024-07-18 02:07:32 字数 348 浏览 7 评论 0原文

我有一个更新面板,在更新面板中我有文件上传控件和按钮控件,单击按钮时,我需要在更新面板的文件上传控件中上传的文件。

确切的场景,我页面上有 8 个选项卡,每个选项卡包含太多信息,其中一个选项卡是附件,当用户单击显示的“添加新附件”模态弹出窗口时,模态包含 Updatepanel 中的详细信息视图,并且在详细信息视图中我有文件上传控件,当用户点击保存按钮,触发detailsview插入事件,在插入事件中我需要我上传的文件。
请注意,我的页面很重,我不想要完整的回发。


有人有办法解决这个问题吗?

预先感谢您的好意帮助......

I have a update panel, in the update panel I have fileupload control and button control, On button click, I need the file that I have upload in the fileupload control in updatepanel.

Exact scenario, I have 8 tabs on page, each tab contains too much information, One of the tab is Attachment, when user click on Add New Attachment Modal Popup shown, Modal contains detailsview in Updatepanel and in the detailsview I have fileupload control, when user hit save button, detailsview inserting event fired, In the inserting event I need the file that I have upload.

Please Note, My page is heavy and I don't want full postBack.

Does anyone have solution of this issue?

Advance thanks for your kind help.....

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

土豪我们做朋友吧 2024-07-25 02:07:32

要解决此问题,请参阅以下步骤。

  1. 将 ajax-upload 添加到您的详细信息视图中。
    • 基于 iframe 的上传器,例如 Resource#1。
    • 基于 Silverlight 的 基于 Flash 的上传器。 我喜欢这种技术,因为它不需要任何服务器端脚本来显示当前上传状态。 但在 HTML5 中,您无需使用任何网络浏览器插件即可创建此内容。
    • 像 Resource#2 这样的商业上传器。使用隐藏的 iframe 进行上传。
  2. 将文件上传到临时位置。

    • 系统响应临时位置。接下来,客户端以详细信息形式将临时位置保留在隐藏输入中。
    • 使用 session_id 保留临时位置。您可以将其存储在数据库或会话变量中,具体取决于您的框架。
  3. 当您点击保存按钮时,系统会将文件移动到其真实位置

注意。 系统会自动从临时位置删除过期的文件。

资源

  1. 实时 ASP.NET 文件上传 进度条
  2. ASP.NET 文件上传,如 GMail(商业)

更新

近一年后,我刚刚找到了一个很好的第三方控件来解决这个问题。 这是一个jQuery的开源插件。 它命名为 Plupload,允许您使用 HTML5、Silverlight、Flash 或普通表单上传文件,并提供一些独特的功能,例如上传进度、图像大小调整和分块上传。

您可以尝试& 单击此处测试 Plupload。

For solve this problem, Please see the following step.

  1. Add ajax-upload to your detail view.
    • iframe-based uploader like Resource#1.
    • Silverlight-based & Flash-based uploader. I like this technique because it doesn't require any server-side script for display current upload status. But in HTML5, you can create this without using any web browser plug-in.
    • Commercial uploader like Resource#2. that use hidden iframe for uploading.
  2. Upload file to temporary location.

    • System response the temporary location. Next, client keep temporary location in hidden input in detail form.
    • Keep temporary location with session_id. You can store it in database or Session variable depend on your framework.
  3. When you click on the save button, the system will move the files to their real location

Note. System will automatically delete the expired file from the temporary location.

Resource

  1. ASP.NET File Upload with Real-Time Progress Bar
  2. ASP.NET File Upload like GMail (Commercial)

Update

After almost one year, I just found a great 3rd-parties control for this question. This is an open source plug-in of jQuery. It name Plupload that allows you to upload files using HTML5, Silverlight, Flash or normal forms and it provide some unique features such as upload progress, image resizing and chunked uploads.

You can try & test Plupload by click here.

独孤求败 2024-07-25 02:07:32

如果客户端上没有安装协作二进制文件,则无法完成此操作。 AJAX 框架没有安全的机制来读取文件的内容并因此能够将其发送到服务器。 浏览器仅支持从文件输入框发送多部分表单。

Can't be done without co-operating binaries being installed on the client. There is no safe mechanism for an AJAX framework to read the contents of a file and therefore be able to send it to the server. The browser supports that only as a multipart form post from a file input box.

蔚蓝源自深海 2024-07-25 02:07:32

问题在于 HTML 文件上传控件的工作方式,与 ASP.net 无关,要使文件上传控件正常工作,您需要表单数据的完整发布。 您只能通过在执行实际上传的隐藏 iframe 中执行所有操作来模拟您没有进行完整的回发

The problem is with the way the HTML file upload control works, has nothing to do with ASP.net, for the file upload control to work you need a full post of the form data. You can only simulate that your are not doing a full postback, by doing all the operation in a hidden iframe that does the actual uploading

ら栖息 2024-07-25 02:07:32

您看到的提供此功能的网站通常使用 flash 或 iframe,以便回发发生在 iframe 中,并给人一种 ajax 请求的错觉。

HTH

OneSHOOT

The sites you see that do provide this functionality generally use flash or an iframe so that the postback occurs in the iframe and gives the illusion of an ajax request.

HTH

OneSHOT

○愚か者の日 2024-07-25 02:07:32

我尝试过 swfupload (http://swfupload.org/),但请记住,您必须如果您在非 IE 浏览器中使用表单身份验证,请跳过这些麻烦。 这显然是一个 flash bug,并且在 flash 10 中没有修复。由于这个 bug,我决定不在我们的框架中使用它,但它在其他方面是一个很棒的产品。

I've tried swfupload (http://swfupload.org/), but do keep in mind that you have to jump through hoops if you're using forms authentication with non-IE browsers. This is apparently a flash bug, and it's not fixed in flash 10. I decided against using it in our framework because of this bug, but it was otherwise a great product.

海的爱人是光 2024-07-25 02:07:32

我推荐 YUI 的上传器小部件。 请参阅 http://developer.yahoo.com/yui/uploader/

我想你可以用它来实现你的目标。 完成上传后,您的 JavaScript 需要将文件从服务器取回到客户端。 但页面不会刷新——上传是通过 Flash 和隐藏的 iframe 进行的。 向用户显示文件内容的下载将通过 ajax 进行。

如果用户不“批准”上传,则只需对服务器再次进行 ajax 调用即可删除文件。

I recommend the uploader widget from YUI. See http://developer.yahoo.com/yui/uploader/

I think you could use it to accomplish your goal. Your javascript would need to fetch the file back down to the client from the server after it completed its upload. But the page would not refresh--the upload is through flash and a hidden iframe. The download to show the file's contents to the user would be via ajax.

If the user does not "approve" the upload, then simply make another ajax call to the server to delete the file.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文