Kanishka
Kanishka

Reputation: 1147

File upload control not working inside update panel

I am using the following code to upload the file

<asp:UpdatePanel ID="UpdatePanel18" runat="server">

   <ContentTemplate>

    <asp:FileUpload runat="server" ID="fuImage1" />

    <asp:Button runat="server" ID="btnUpload1" Text="Upload" 
                               onclick="btnUpload1_Click" />
    <asp:ImageButton ID="btnGetImage1" ImageUrl="images/cam.png" Height="25px" 
                        Width="25px" runat="server" onclick="btnGetImage1_Click" />    
    </ContentTemplate>
    <Triggers>
        <asp:PostBackTrigger ControlID="btnUpload1" />
    </Triggers> 
</asp:UpdatePanel>

When i select a file to upload, path is not getting displayed on the file upload control. Need help to fix this problem

Upvotes: 1

Views: 3836

Answers (2)

Jidheesh Rajan
Jidheesh Rajan

Reputation: 4845

This should work

<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true" />
    <div>
        <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="conditional">
            <Triggers>
                <asp:PostBackTrigger ControlID="Button1" />
            </Triggers>
            <ContentTemplate>
                 <asp:FileUpload ID="FileUpload1" runat="server" />
                 <asp:Button ID="Button1" runat="server"Text="Upload" OnClick="Button1_Click" />
            </ContentTemplate>
        </asp:UpdatePanel>
    </div>

Upvotes: 0

Abe Miessler
Abe Miessler

Reputation: 85056

This is a frustrating feature of the update panel. Give this post a read which goes over the cause of this issue as well as a resolution:

http://geekswithblogs.net/mmintoff/archive/2009/04/01/fileupload-within-updatepanel.aspx

Upvotes: 4

Related Questions