I got an interesting problem today. When FileUpload control is placed in an UpdatePanel, HasFile property is always false. It is not only the HasFile property which is false but also other attributes like file name and length are set to blanks and zeros.
If the FileUpload control is pulled out of UpdatePanel, the problem is solved.
Can anyone please tell me how to make FileUpload controls to work with UpdatePanels?
The FileUpload control doesn't work with an asynchronous postback, such as the UpdatePanel causes.
From MSDN:
Using the FileUpload Control in Partial-Page Updates
The
FileUpload control is designed to be used only in postback scenarios and not in asynchronous postback scenarios during partial-page 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. For more information, see
UpdatePanel Control Overview and
Partial-Page Rendering Overview.
<div class="subsection"> </div>
"Sometimes I think the surest sign that intelligent life exists elsewhere in the universe is that none of it has tried to contact us."
Gopinathmuni...
Member
9 Points
39 Posts
FileUpload.HasFile is always False When Used with UpdatePanel
Apr 14, 2008 01:23 PM|LINK
Hello,
I got an interesting problem today. When FileUpload control is placed in an UpdatePanel, HasFile property is always false. It is not only the HasFile property which is false but also other attributes like file name and length are set to blanks and zeros.
If the FileUpload control is pulled out of UpdatePanel, the problem is solved.
Can anyone please tell me how to make FileUpload controls to work with UpdatePanels?
Cheers,
Gopi
Do you know your blog/web site page rank? Check Google Page Rank Now
ramblor
Contributor
6676 Points
1013 Posts
Re: FileUpload.HasFile is always False When Used with UpdatePanel
Apr 14, 2008 01:41 PM|LINK
The FileUpload control doesn't work with an asynchronous postback, such as the UpdatePanel causes. From MSDN:
<div class="subsection"> </div>chetan.sarod...
All-Star
66609 Points
11270 Posts
Re: FileUpload.HasFile is always False When Used with UpdatePanel
Apr 15, 2008 03:27 AM|LINK
FileUpload control are not compatible with Update Panel when they are used to upload files as part of an asynchronous postback.
http://asp.net/ajax/documentation/live/overview/UpdatePanelOverview.aspx
Try to use <input type= "File" id="fileUpload" name="fileUpload" />
See here building AJAX enabled File Upload control
http://aspalliance.com/1442_Building_AJAX_Enabled_File_Uploading_System_with_Progress_Bar_Using_ASPNET_20.all
http://geekswithblogs.net/rashid/archive/2007/08/01/Create-An-Ajax-Style-File-Upload.aspx
http://msmvps.com/blogs/luisabreu/archive/2006/12/14/uploading-files-without-a-full-postback.aspx
http://blogs.infragistics.com/blogs/tony_lombardo/archive/2007/04/09/file-uploads-where-s-the-ajax.aspx
http://www.codeproject.com/KB/aspnet/AJAXUpload.aspx
http://forums.asp.net/t/1207035.aspx
Senior Software Engineer,
Approva Systems Pvt Ltd, Pune, India.