[英]update panel with file upload
<asp:FileUpload runat="server" ID="uploadCertification" />
<asp:Button runat="server" ID="btntext" OnClick="btntext_Click" />
Code代码
uploadCertification.PostedFile.SaveAs(serverPathImage + "\\CertificationCompany\\as.td");
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代码
uploadCertification.PostedFile.SaveAs(serverPathImage + "\\CertificationCompany\\as.td");
this line say error: Object reference not set to an instance of an object.此行显示错误:Object 引用未设置为 object 的实例。
Take a look at using a PostBackTrigger within your UpdatePanel:看看在 UpdatePanel 中使用 PostBackTrigger:
The above MSDN article contains a code listing for using a PostBackTrigger with a FileUpload control.上面的 MSDN 文章包含使用带有 FileUpload 控件的 PostBackTrigger 的代码清单。
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)您可用的其他方法是使用 iframe 方法(在其他答案之一中提到)或使用使用 javascript 和 flash 的众多第三方组件之一来上传文件下面比较流行的)
Unfortunatly the UpdatePanel does not work with some controls, notably the FileUpload control.不幸的是,UpdatePanel 不适用于某些控件,尤其是 FileUpload 控件。 I believe there is a problem with uploading files using javascript.我相信使用 javascript 上传文件存在问题。 Have a look here http://msdn.microsoft.com/en-us/library/bb386454.aspx for a better explaination.看看这里http://msdn.microsoft.com/en-us/library/bb386454.aspx以获得更好的解释。
I have got around this problem in the past using an Iframe on a seperate page that does the upload.过去,我在一个单独的页面上使用 Iframe 解决了这个问题。 http://www.codeproject.com/KB/aspnet/FileUploadingWithLoading.aspx http://www.codeproject.com/KB/aspnet/FileUploadingWithLoading.aspx
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.