Asp.net Upload File Hasfile Always False

0817

  1. Asp.net Upload File Hasfile Always False

I'm developing an ASP.NET application with. I make a full postback to upload the file to the server. FileUpload and UpdatePanel: FileUpload.HasFile is always.

FileUpload and UpdatePanel: FileUpload.HasFile is always FALSE.

Feb 15, 2010 10:48 AMVansFannelLINK

Hello.

I'm developing an ASP.NET application with C# and Visual Studio 2008 SP1. I'm using WebForms.

Asp

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:

<asp:UpdatePanel runat='server' RenderMode='Inline'
UpdateMode='Conditional'>
<ContentTemplate>
<asp:Button runat='server' Text='Guardar'
CssClass='button' />
</ContentTemplate>
<Triggers>
<asp:PostBackTrigger ControlID='Save' />
</Triggers>
</asp:UpdatePanel>

Asp.net Upload File Hasfile Always False


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.

Upload file asp net core

Any advice?

Thank you.

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 Postback. But, I am not sure what would exactly resolve my problem.

Amit TyagiAmit Tyagi

1 Answer

Asp.net Upload File Hasfile Always False

Inorder to retain the selection during PostBack you should enable the view state property as below

Rest Approach

Amal HashimAmal Hashim

Not the answer you're looking for? Browse other questions tagged 2013web-partfile-upload or ask your own question.

This entry was posted on 17.08.2019.