简体   繁体   English

带有文件上传的更新面板

[英]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:

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 的众多第三方组件之一来上传文件下面比较流行的)

Uploadify上传

SWFUpload SWF上传

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.

相关问题 uplodify上传(文件上传)在更新面板中不起作用? - uplodify upload (File Upload) is not working in Update Panel? 在更新面板中显示带有文件上传的进度更新 - Show Progress Update with File Upload in Update Panel 更新面板中的文件上传控件 - File upload control inside update panel 更新面板内的异步文件上传和触发回发的下拉菜单不起作用 - Asynchronous file upload inside a update panel and a dropdown to trigger postback not working 更新面板中的文件上载控件始终返回false - File Upload control in update Panel Always returns false 文件上载在Ajax更新面板的页面中不起作用 - File Upload doesn't work in a page with Ajax Update Panel HTML输入文件控件在更新面板中使用时不上传文件 - Html input file control doesn't upload file when used in update panel 即使在asp.net中存在文件,“更新”面板中的文件上传也不会出错 - File upload not in Update panel hasfile coming false even if file is present in asp.net 在更新面板中的文件上传控件中丢失文件 c# asp.net - Losing file in a file upload control in update panel c# asp.net 异步实现文件上传控制时,UpdateProgress和触发器部分在“更新”面板中不起作用 - UpdateProgress and trigger section not working in Update panel while implement file upload control asynchronously
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM