Asp.net Upload File Hasfile Always False
File Upload Hasfile Always False
If you are using update panel write trigger for submit button. Then if you click on it your file upload will be working fine. // HTML code. Please mark as answer if find useful.
I'm developing an ASP.NET application with C# and Visual Studio 2008 SP1. I'm using WebForms. I have an ASPX page with two UpdatePanels, one on the left that holds a TreeView and other on the right where I load dynamically user controls. One user control, that I used on right panel, has a FileUpload control and a button to save that file on server. The ascx code to save control is: I make a full postback to upload the file to the server and save it to database.
But I always getting False on FileUpload.HasFile. I problem is the right UpdatePanel. I need it to load dynamically the user controls. This panel has three UpdatePanels to load the three user controls that I use. Maybe I can use an Async File Uploader or delete the right Update Panel and do a full postback to load controls dynamically. Reebdoog Just incase you're still wondering. Put this in the PageLoad Page.Form.Attributes.Add('enctype', 'multipart/form-data'); It fixes the problem of the first postback causing a false to appear.
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.
Just incase someone stubbles across this from google, the above worked for me. I am doing the same thing - I have a page with an update panel. Make sure that the upload buttons is in PostBackTriggers for the Update Panel. In this update panel, I dynamically load user controls. Most of the user controls have an upload file option. Everything other button works fine, except the file upload button. The file upload button only worked on the second key press.
After adding the above line to the Parent Page, everything worked as expected. Hi friend,just the mark up should be like this,then FileUpload.HasFile will true.Check this with your markup.