AjaxUploader autopostback problem with MVC

Last post 11-01-2012, 8:13 AM by Kenneth. 5 replies.
Sort Posts: Previous Next
  •  10-11-2012, 3:23 AM 74948

    AjaxUploader autopostback problem with MVC

    Hi there,

     

    We are considering about the probability to use the commercial version of AjaxUploader. So currently, we are testing (Uploading multiple files like GMail package) and trying to integrate AjaxUploader to our MVC applications. We tested it as a single component and it worked perfectly. But when we integrated it to our MVC components, we had a problem with autopostback. When we clicked Upload button, the select files dialog even didn't show up, it's postback and sent directly to server side and the Exception occurred. Could someone please help me out of this problem, how to stop autopostback? Any thought appreciated!


    Thanks in advance.
    Regards,
    Qui. 

  •  10-11-2012, 7:16 AM 74954 in reply to 74948

    Re: AjaxUploader autopostback problem with MVC

    Hi QuiTran,
     
    I suggest you use start upload manually mode, like demo http://www.ajaxuploader.com/Demo/Start-uploading-manually.aspx, then you can handle the page post back by your code.
     
    You will find the MVC start upload manuall example in the uploader mvc  demo folder too.


    Regards,


    Ken
  •  10-11-2012, 9:56 AM 74960 in reply to 74954

    Re: AjaxUploader autopostback problem with MVC

    Hi Ken,

     

    Thanks for your response. I did try your suggestion,  but I got the same problem. The problem is that, my MVC is dynamic form. The form's elements are rendered from database, each element has its appropriate view, for example, element type button has its view button.cshtml, type input has its view input.cshtml and so on. When I tried to integrated Upload button to this form, whenever I clicked it, the submit event was automatically called, its controller's actions were not called. And that caused all the problems. Do you have any new approach?

     

    Thanks,

    Regards,

    Qui

  •  11-01-2012, 7:06 AM 75128 in reply to 74960

    Re: AjaxUploader autopostback problem with MVC

    Hi Qui,

     

    I've seen this issue as I just started to search for a truly AJAXified FileUpload control. I believe you will see similar issue with any FileUpload control if loaded dynamically. The trick is (at least for me) to drop a "dummy" Uploader control to the ASPX page which is static and not dynamic, with just the ID and runat attribute. This will ensure that between postbacks the control's hooking are there ready to use. Once this is done the and you click the button it should just pop up the file browsing window. I use an web application and this trick has fixed it for me.

     

    Regards,

    Ben

  •  11-01-2012, 7:11 AM 75129 in reply to 75128

    Re: AjaxUploader autopostback problem with MVC

    Of course the dummy uploader must be of the same type you use on your dynamic form. Also for  the dummy Uploader to make it not visible set the style="display:none;" so it won't be visible to the user.

     

    Regards,

    Ben

  •  11-01-2012, 8:13 AM 75131 in reply to 74960

    Re: AjaxUploader autopostback problem with MVC

    Hi QuiTran,

     

     

    I think you have not set uploader.ManualStartUpload = true; this is why the uploader do the post back after you select the files. Can you show me your uploader code?

     

    Regards,

     

    Ken 

View as RSS news feed in XML