Asp.net的fileupload控件回发问题 [英] Asp.net fileupload control postback problems

查看:1015
本文介绍了Asp.net的fileupload控件回发问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用ASP.net,vs2008 C#。

我使用WebForm上的FileUpload控件。上传一个文件(即PDF分发)到服务器目录工作正常。



我在网络上有一个预览按钮,用户可以用来预览PDF文件通过Fileupload浏览功能选中之后。
我是这样做的
$ b $ pre $ if $($ this $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ local $ = FileUpload1.PostedFile.FileName;
//使用此预览文件。其他方法受当地安全要求限制
Process.Start(localURL);

$ / code>

我的问题是在按钮单击Postback后,所选文件的位置消失在Fileupload控件的文本框部分。



如何保存这些信息,用户不必再次浏览,而只需点击上传即可上传文件。

任何帮助赞赏



谢谢

试着把localURL变量放到一个会话中。为我工作过一次

using ASP.net, vs2008 C#.

Im using a FileUpload control on a webform. The uploading of a file (ie PDF dcouments) to a server directory works ok.

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. 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.

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. worked for me once

这篇关于Asp.net的fileupload控件回发问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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