更新面板文件上传 [英] update panel with file upload

查看:87
本文介绍了更新面板文件上传的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<asp:FileUpload runat="server" ID="uploadCertification" />
<asp:Button runat="server" ID="btntext" OnClick="btntext_Click" />

code

Code

uploadCertification.PostedFile.SaveAs(serverPathImage + "\\CertificationCompany\\as.td");

这code工作正常,但当

this code work fine but when

 <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
      <asp:UpdatePanel ID="UpdatePanel3" runat="server"><ContentTemplate>
     <asp:FileUpload runat="server" ID="uploadCertification" />
      <asp:Button runat="server" ID="btntext" OnClick="btntext_Click" />
</ContentTemplate></asp:UpdatePanel>

code

Code

 uploadCertification.PostedFile.SaveAs(serverPathImage + "\\CertificationCompany\\as.td");

这行说错误:对象引用不设置到对象的实例

this line say error: Object reference not set to an instance of an object.

推荐答案

看看使用PostBackTrigger您的UpdatePanel内:

Take a look at using a PostBackTrigger within your UpdatePanel:

PostBackTrigger

以上MSDN文章包含一个code房源为使用PostBackTrigger用FileUpload控件。

The above MSDN article contains a code listing for using a PostBackTrigger with a FileUpload control.

可供您使用其它方法是使用的iframe方法(在其他的答案中的一个提到的),或者使用许多第三方组件在那里它使用JavaScript和Flash中的一个上传文件(找到链接到一个情侣以下的较受欢迎的)

Other approaches available to you are to use the iframe approach (mentioned in one of the other answers) or to use one of the many third party components out there which make use of javascript and flash to upload files (Find links to a couple of the more popular ones below)

Uploadify

SWFUpload的

这篇关于更新面板文件上传的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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