[英]How to avoid fileupload text clearing?
Iam using VS2015. Iam使用VS2015。 Now Iam preparing a small project in ASP.Net. 现在Iam在ASP.Net中准备一个小项目。 Iam using a control FileUpload. Iam使用控件FileUpload。
ASPX - Page asp:FileUpload ID="FileUpload1" runat="server" ClientIDMode="Static" onchange="this.form.submit()" BackColor="Purple" style="font:20px calibri; border:5px solid blue; Width:100%; Height:100%;" ASPX.CS PAGELOAD String MyExcelFile = FileUpload1.PostedFile.FileName;
The problem is after executing this above statement, the FileUpload1 clearing the Text value. 问题是执行上述语句后,FileUpload1清除了Text值。 So is it possible to display the readed file in FileUpload1. 因此可以在FileUpload1中显示读取的文件。
Note : Iam looking for FileUpload only. 注意:我只在寻找FileUpload。 It's not required to have Upload button & Label. 不需要具有“上传”按钮和标签。 I need to use FileUpload only but the content of browse textbox should not clear. 我只需要使用FileUpload,但浏览文本框的内容不应清除。 Thanks again. 再次感谢。
You could add a 'upload file' button, while you remove the onchange="this.form.submit()" so the fileupload selection won't cause a postback. 您可以在删除onchange =“ this.form.submit()”的同时添加一个“上传文件”按钮,以便选择文件上传不会引起回发。
This way, when you click the 'upload file' button, on your event handler (eg. uploadFile_Click function) you'll have Access to the filename in the FileUpload control. 这样,当您单击“上传文件”按钮时,在事件处理程序(例如uploadFile_Click函数)上,您将可以访问FileUpload控件中的文件名。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.