Required Help in File Uploading with Ajax Update panel

Last post 08-18-2007 10:00 AM by Mahadeomatre. 2 replies.

Sort Posts:

  • Required Help in File Uploading with Ajax Update panel

    08-18-2007, 3:53 AM
    • Loading...
    • Mahadeomatre
    • Joined on 04-23-2007, 7:00 AM
    • Pune, India
    • Posts 210

    Hello,

    I want to upload the file in my application. when I write the code without using ajax update panel, then it is uploading the file.

    but when i use update panel, then file is not uploading file, it showing there is no any file in the upload control.

    my code is as follows

     HTML view

    <form id="form1" runat="server">

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

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

    <ContentTemplate>

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

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

    </ContentTemplate>

    </asp:UpdatePanel>

    </form>

       and i just written in code behind

    protected void Button1_Click(object sender, EventArgs e)

    {

    if (FileUpload1.HasFile)

    {

    Response.Write(FileUpload1.FileName.ToString());

    }

    }

    but it giving the exception.

    please help me..

     

    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.
    Filed under:
  • Re: Required Help in File Uploading with Ajax Update panel

    08-18-2007, 5:01 AM
    Answer
    • Loading...
    • joteke
    • Joined on 06-16-2002, 11:24 AM
    • Kyro, Finland
    • Posts 6,359
    • ASPInsiders
      Moderator
      TrustedFriends-MVPs

    Uploads cannot be done in ASP.NEt Ajax e.g they always require a full postback. But to work in conjuction with UpdatePanel while other parts of the UpdatePanel work in async manner, you'd need to attach a PostBackTrigger to the Button triggering upload

    <Triggers>
        <asp:PostBackTrigger ControlID="Button1" />
        </Triggers>

    ASP.NEt Ajax's documentation covers this exact case (Upload in UpdatePanel/PostBAckTrigger). It's at: http://www.asp.net/ajax/documentation/live/ViewSample.aspx?sref=System.Web.UI.PostBackTrigger%23PostBackTriggerCS.aspx

     

    Thanks,

    Teemu Keiski
    Finland, EU
  • Re: Required Help in File Uploading with Ajax Update panel

    08-18-2007, 10:00 AM
    • Loading...
    • Mahadeomatre
    • Joined on 04-23-2007, 7:00 AM
    • Pune, India
    • Posts 210

    Thnaks for reply..

    my problem is solved.

    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.
Page 1 of 1 (3 items)