[RESOLVED] FileUpload control don't work on first submission


I'm having a problem with the FileUpload control in ASP.NET. It requires two postbacks to server in order to upload the file. In other words, after I select the file and click upload the page reloads but do nothing. Then I reselect the file and click upload then it works.

In my code I put a check for FileUpload.HasFile and it always fails (return false) on the first postback. 

Does anybody have any information regarding this problem?



Are you using fileupload inside update panel. Please post relevant code here


Yes I did, here's the code.

<asp:UpdatePanel ID="upDefault" runat="server" UpdateMode="Conditional">
                    <asp:PostBackTrigger ControlID="UploadButton" />
                        <asp:FileUpload ID="HinhFU" runat="server" CssClass="largectl" ValidationGroup="UpByFile" />
                        <asp:RequiredFieldValidator ID="rfvFU" runat="server" ErrorMessage="*" ValidationGroup="UpByFile" ControlToValidate="HinhFU" >
                        <asp:Button runat="server" ID="UploadButton" Text="Upload" ValidationGroup="UpByFile" />

                    <asp:Image runat="server" ID="HinhSVImg" Width="100" Height="150" ImageUrl="" Visible="false" />


In the uploadbutton click I just check for HinhSV.HasFile, if yes then upload it with HinhSV.SaveAs().




In the uploadbutton click I just check for HinhSV.HasFile

I am not sure whether its your mistake while posting! But as per your code there is a fileupload control with id HinhFU and not HinhSV.Innocent

thoughts on "[RESOLVED] FileUpload control don't work on first submission"

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>