File upload control not working with update panel.

Last post 05-09-2008 8:11 AM by okkko. 3 replies.

Sort Posts:

  • File upload control not working with update panel.

    05-09-2008, 4:25 AM

    Hi,

     I am using a file upload control within update panel. but I am not getting the filename on server side. Is there any problem with update panel?

    How can I solve this issue? I am hereby attaching sample code for file upload control with update panel.

    <asp:ScriptManager ID="ScriptManager1" runat="server">

    </asp:ScriptManager>

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

    <ContentTemplate>

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

    <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />

    </ContentTemplate>

    </asp:UpdatePanel>

     

    Code Behind

    protected void Button1_Click(object sender, EventArgs e)

    {

    if (FileUpload1.HasFile)

    {

    string filename = FileUpload1.FileName;

    }

    }

  • Re: File upload control not working with update panel.

    05-09-2008, 5:03 AM

    Hello,

    FileUpload will not work in the updatepanel. Try this control

    http://en.fileuploadajax.subgurim.net/

     

    Regards 

  • Re: File upload control not working with update panel.

    05-09-2008, 5:05 AM
    Answer
    • Loading...
    • Mahadeomatre
    • Joined on 04-23-2007, 11:00 AM
    • Pune, India
    • Posts 210

    actually fileupload control requires full postback. but update panel will do the partial postback, so that u are not getting the file name.

    to get file name of uploaded file use updatepanels postback trigger, add ur file upload ctrl in this trigger. this will work.

    for more information please refer this

    http://forums.asp.net/t/1147992.aspx

    Thanks,
    Mahadeo

    -----------------------------------------------
    Best is Not the END point, but a starting point for Innovation
    ------------------------------------------------
    Remember to mark posts as the "Answer" to help future users.
  • Re: File upload control not working with update panel.

    05-09-2008, 8:11 AM
    Answer
    • Loading...
    • okkko
    • Joined on 01-08-2008, 11:32 AM
    • Slovenia
    • Posts 47
     
    protected void Page_PreRender(object sender, System.EventArgs e)
    {
         this.ScriptManager1.RegisterPostBackControl(Button1);    
    }
     
    This will of course cause a full page postback.
Page 1 of 1 (4 items)