Reputation: 613
Iam using VS2015. Now Iam preparing a small project in ASP.Net. Iam using a control 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. So is it possible to display the readed file in FileUpload1.
Note : Iam looking for FileUpload only. It's not required to have Upload button & Label. I need to use FileUpload only but the content of browse textbox should not clear. Thanks again.
Upvotes: 0
Views: 617
Reputation: 841
You could add a 'upload file' button, while you remove the onchange="this.form.submit()" so the fileupload selection won't cause a postback.
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.
Upvotes: 2