Posts Tagged ‘updatePanel’

Using FileUpload Control with UpdatePanel Control

July 10, 2010 1 comment


When you try to implement a ASP.NET FileUpload control in AJAX, you will not be able to upload your file. This is because, FileUpload1.HasFile function will always return you a false value.



The reason why FileUpload1.HasFile always return you a false value is because, the FileUpload control is designed to be used only in PostBack scenarios and not in Asynchronous PostBack scenarios during partial rendering. When you use a FileUpload control inside an UpdatePanel control, the file must be uploaded by using a control that is a PostBackTrigger object for the panel. UpdatePanel controls are used to update selected regions of a page instead of updating the whole page with a postback.

Step-By-Step Guide:

[Assuming that you already have the your UpdatePanel, FileUpload, and Button Control in placed]

  1. Add “ enctype="multipart/form-data" ” to your form tag.
  2. Add a PostBackTrigger to the Triggers section in the UpdatePanel Control.
  3. Set the ControlID to the ID of your Button for the PostBackTrigger


Below are sample codes for your reference:



C# Code:



VB Code:


Categories: ASP.NET Tags: , , ,