Home > ASP.NET > Using FileUpload Control with UpdatePanel Control

Using FileUpload Control with UpdatePanel Control


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: , , ,
  1. Ronnie
    July 17, 2010 at 10:19 pm

    I hoped this would work. but on VB Code Visual Web Developer 2010 kicked back on everything. Thanks

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: