如何上传使用asp.net的文件,而无需缴纳了整页? [英] How to upload a file using asp.net without posting the whole page back?

查看:117
本文介绍了如何上传使用asp.net的文件,而无需缴纳了整页?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用asp.net所以我不想回发,而上传页面上传文件。我怎样才能做到这一点,有没有什么办法使用Ajax来做到这一点。

I want to upload a file using asp.net so I do not want to post back the page while uploading . How can I do that and is there any way to do it using Ajax .

推荐答案

请在文件上传表单针对一个隐藏的iframe。

Make the file upload form target a hidden iframe.

<iframe name="UploadTarget" style="display:none"></iframe>
<form target="UploadTarget" action="postfile" method="post" enctype="multipart/form-data">
<input type="file" name="MyFile">
<input type="submit" name="submit" value="Send me a file">
</form>

最后一个诀窍是要添加到您的回复页面:

The final trick is to add to your response page:

<script type="text/javascript">parent.somecallbackfunction("Here is some data")</script>

要让你的父页面(包含隐藏的iframe的那个)知道,文件上传完成。

To let your parent page ( the one containing the hidden iframe) know that the the file upload has completed.

这篇关于如何上传使用asp.net的文件,而无需缴纳了整页?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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