简体   繁体   English

ASP.NET文件上传控制回发问题

[英]Asp.net fileupload control postback problems

using ASP.net, vs2008 C#. 使用ASP.net,vs2008 C#。

Im using a FileUpload control on a webform. 我在网络表单上使用FileUpload控件。 The uploading of a file (ie PDF dcouments) to a server directory works ok. 将文件(即PDF dcouments)上传到服务器目录可以正常进行。

I have on the webform a "preview" button that the user can use to preview the PDF file after they have selected it via the Fileupload browse feature. 我在Web表单上有一个“预览”按钮,用户可以通过Fileupload浏览功能选择PDF文件后预览它。 I do this by 我这样做

  if (this.FileUpload1.HasFile)
      {
        localURL = FileUpload1.PostedFile.FileName;
        // use this to preview file. Other methods are restricted by local security requirements
        Process.Start(localURL);
      }

My problems is that after the button click Postback occurs the location of the selected file disappears from the textbox part of the Fileupload control. 我的问题是,在单击“回发”按钮后,所选文件的位置从Fileupload控件的文本框部分消失了。

How can i keep this info there, so the user does not have to browse again and instead can just click upload to upload the file. 我如何在此处保存此信息,因此用户不必再次浏览,而只需单击“上传”即可上传文件。

Any help appreciated 任何帮助表示赞赏

thanks 谢谢

try putting the localURL variable into a session. 尝试将localURL变量放入会话中。 worked for me once 为我工作过一次

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM