C# – FileUpload.PostedFile always null inside UpdatePanel

asp.netcfile uploadupdatepanel

I have a FileUpload control inside an UpdatePanel. I have successfully registered the upload button with the scriptmanager to do a full postback. The only issue I have is that FileUpload.HasFile is always returning null.
Note: When I move the FileUpload control outside of the updatepanel everything works file. Is there a solution or workaround for this.

Thanks.

Best Answer

You can put a FileUpload control in an UpdatePanel but you have to use a PostBackTrigger as opposed to an AsyncPostBackTrigger. I recently used this approach and combined both types of trigger.

    <Triggers>
        <asp:PostBackTrigger ControlID="btnSave" />
        <asp:AsyncPostBackTrigger ControlID="btnAsyncSave"/>
    </Triggers>

The PostBackTrigger was used for FileUploads while the AsyncPostBackTrigger was used for all the other form fields.