FileUpload.PostedFile always null inside UpdatePanel

Steven picture Steven · Jun 7, 2011 · Viewed 32.8k times · Source

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.

Answer

rf_wilson picture rf_wilson · Feb 28, 2013

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.