File upload with ASP.NET AJAX UpdatePanel

I’ve been working with the Microsoft AJAX toolkit recently (and not so much Windows Mobile – hence lack of update 🙂 . It’s an amazing framework for people who don’t know much JavaScript but still would like to do some AJAX style web programming (like me). However since it involves a combination of .NET server side programming, HTML and client side JavaScript figuring out what’s wrong when something doesn’t work can be tricky. I’ll try to post a few tricks I found (mostly on  🙂 even though it’s not directly related to mobile programming.

The ASP.NET FileUpload control doesn’t work within an AJAX UpdatePanel by default (when the upload button you create is inside the same panel). This is because a file cannot be uploaded asynchronously. To be able to upload a file the easiest solution is to make a complete postback when the user uploads a file. To do this add a PostBackTrigger on the button:

<asp:Button ID="ButtonUploadFile" 
    runat="server" Text="Upload" /> 
<asp:PostBackTrigger ControlID="ButtonUploadFile" /> 

(note that it is not an AsyncPostBackTrigger)


21 Responses to File upload with ASP.NET AJAX UpdatePanel

  1. vpanta says:

    The first time, upload not function, why ?

  2. Ali Ahmad says:


    Try this

    in place of

    Let me know if you further face some problem.


  3. Ali Ahmad says:

    Try this

    in place of

    Previously I copied and paste but not shown in above, as you can see.

  4. matt ridley says:

    in response to vpanta, take a look at this, worked for me….

  5. Grozny says:

    Somehow i missed the point. Probably lost in translation 🙂 Anyway … nice blog to visit.

    cheers, Grozny.

  6. Anonymous says:

    this is not working
    when we browse file
    after 20 second these are lost
    please send me solution.
    Thanks in advance

  7. hans says:

    thanks for this post !

  8. agsy says:

    this is crap! It doesn’t work at all!!!

  9. 1 says:

    Bad.. this method isn’t the best form for get the solution to this problem… The best form, though it have more difficulty is use Iframes.

  10. MSB-Soft says:

    Thinking with your

  11. webdesign bg says:

    webdesign bg…

    […]File upload with ASP.NET AJAX UpdatePanel « Mobiledeveloper[…]…

  12. Very good work. I really relished File upload with ASP.
    NET AJAX UpdatePanel | Mobiledeveloper. I hope you don’t mind me personally declaring this however it reminded me of chronic high blood pressure which I find out about on another web page.

  13. Often it’s assumed that everybody has understanding of computers and all that goes with them. Lecturers and Professors use to blog to document their lessons that ey have discussed and taught. Identify your business needs and build pages accordingly.

  14. Hi, i think that i saw you visited my blog so i came to
    “return the favor”.I am attempting to find things to improve
    my web site!I suppose its ok to use a few of your

  15. I think this is one of the most significant information for me.
    And i’m glad reading your article. But should remark on few general things, The web
    site style is perfect, the articles is really excellent : D.

    Good job, cheers

  16. Johnb307 says:

    Howdy very nice web site!! Guy .. Excellent .. Superb .. I’ll bookmark your web site and take the feeds additionallyI am glad to search out so many helpful info here in the put up, we want develop more techniques in this regard, thanks for sharing. eecgbebkggge

  17. I am really loving the theme/design of your weblog. Do you ever run into
    any browser compatibility problems? A handful of my blog readers have complained about my blog not working correctly in Explorer but looks great in Safari.
    Do you have any suggestions to help fix this issue?

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: