I have a FileUpload control (and it's not inside an UpdatePanel) and its hasFile property is always False. Hi,I have a problem with a FileUpload control. When try to I upload a file with it, HasFile always yields false. I was using it within an AJAX UpdatePanel, tried to do a full postback by using a Trigger, tried putting it outside the UpdatePanel, and even removed all the AJAX controls, but HasFile still yields false all the time. ASP.NET's 'AJAX' thing doesn't support file uploads in UpdatePanels out of the box. Change that trigger into a PostBackTrigger (which causes a full page load) or use something else to upload the file. Hence when you place FileUpload control in AJAX UpdatePanel and try to upload the file asynchronously using the PostedFile property is always NULL and the HasFile property is always false. TAGs: ASP.Net.
Active1 year, 1 month ago
I am creating a visual web-part for my SharePoint 2013 environment. I am using
asp:FileUpload
control(fuBrowseXMLFile
) in this web-part for uploading files to a document library. I have a button Save
to initiate the process of uploading the file.After deploying the code, i try to run it in
Debug
mode. I found that after clicking the Save
button, when the debugger hits the following line of code,fuBrowseXMLFile.HasFile
returns FALSE
. Whereas the file is selected in the control.While searching for a solution, I came across lot of articles. But, unfortunately most of them talk with reference to
UpdatePanel
. I am not using UpdatePanel
here.I understand that it has to do something with
Amit TyagiAmit TyagiPostback
. But, I am not sure what would exactly resolve my problem.70511 gold badge1414 silver badges3131 bronze badges
1 Answer
Inorder to retain the selection during
PostBack
you should enable the view state property as belowRest Approach
Gaurravs3,40366 gold badges1616 silver badges2828 bronze badges
Amal HashimAsp.net Upload File Hasfile Always False
Amal Hashim27.5k55 gold badges2525 silver badges6060 bronze badges
Not the answer you're looking for? Browse other questions tagged 2013web-partfile-upload or ask your own question.
Active2 years, 11 months ago
I am uploading file using ASP.net File upload control.My FileUpload1.HasFile is always returning false.
I am using following ASP.net Code
I have tried even by removing AsyncPostBackTrigger and even by removing Whole asp:updatePanel then also my FileUpload1.HasFile always returns false.
AbhiAbhi3,23799 gold badges6565 silver badges120120 bronze badges
3 Answers
ASP.NET's 'AJAX' thing doesn't support file uploads in UpdatePanels out of the box. Change that trigger into a
Matti VirkkunenPostBackTrigger
(which causes a full page load) or use something else to upload the file.Asp.net File Upload
Matti Virkkunen53.8k66 gold badges102102 silver badges140140 bronze badges
Add a trigger for your UpdatePanel
This will force a postback when the upload button is clicked.
Also add the line below to the Page_Load
dbFrameIT SupportdbFrameIT Support
![Upload Upload](/uploads/1/3/3/9/133915503/361397558.gif)
I know this post if old, but I found that if the file is empty [ 0 KB ] then it will return false as well. There has to be something in the file in order for .HasFile to acknowledge it.
Asp Upload File To Server
DoubleDevDoubleDev