Disable ajax before file upload to client, how to enable it afterwards?

9 posts, 0 answers
  1. Antoine
    Antoine avatar
    6 posts
    Member since:
    Mar 2008

    Posted 01 May 2008 Link to this post

    Hello,

    We currently offer our users to download some pdf's from a radGrid thus, we need to disable ajax so we can "push" the file directly to the client without opening a new window.

    So on the event "OnRequestStart" of our RadAjaxManager we have this script that disable ajax and it works great. But after the file is pushed, we need to re-enable ajax so crontrols like "RadCombobox" start working again.

    function onRequestStart(ajaxManager, eventArgs) 
      if(eventArgs.EventTarget.indexOf("lnkbtnUpload") != -1) 
      { 
         eventArgs.EnableAjax = false
      } 

    We tried OnRequestEnd, but didn't work. This event is not event fired, which is probably due to the fact that "ajax" is disabled.

    How could this be achieved?

    Thanks!
  2. Konstantin Petkov
    Admin
    Konstantin Petkov avatar
    1911 posts

    Posted 01 May 2008 Link to this post

    Hello Oliver,

    Thank you for contacting us.

    Indeed, this is a correct approach when working with AJAX and exporting Grid functionality. I should add however that this should not break any subsequent controls ajaxification. Note that the event is fired for each AJAX request
    disabling the AJAX for this particular request only. If the next AJAX initiator is your combobox for example, the code won't disable that.

    Does the combobox works as expected before the exporting postback? Do you mean it performs a regular postbacks after that?

    Kind regards,
    Konstantin Petkov
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Antoine
    Antoine avatar
    6 posts
    Member since:
    Mar 2008

    Posted 01 May 2008 Link to this post

    Hi,

    Actually we are not using the grid export functions. We use custom stuff.

    What happens is that when the "download pdf" button is clicked within the grid, the following function is called to push the file to client. As I said earlier on, the OnRequestStart ajax is disabled for this to work.

    ...SOME CODE... 
     
    // FOR HTTPS 
                HttpContext.Current.Response.AddHeader("Accept-Header", targetFile.Length.ToString()); 
     
                // add the header that specifies the default filename for 
                // the Download/SaveAs dialog 
                HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=" + targetFile.Name); 
     
                // add the header that specifies the file size, so that the browser 
                // can show the download progress 
                HttpContext.Current.Response.AddHeader("Content-Length", targetFile.Length.ToString()); 
     
                // specify that the response is a stream that cannot be read by the 
                // client and must be downloaded 
                HttpContext.Current.Response.ContentType = GetFileType(targetFile.FullName.ToLower()); 
     
                // send the file stream to the client 
                HttpContext.Current.Response.WriteFile(targetFile.FullName); 
     
                // stop the execution of this page 
                HttpContext.Current.Response.End(); 

    But after the download prompt is presented to user, file is downloaded and everything is fine except for the "RadComboBox's" in the form.

    They simply are disabled / non-functional, they wont even drop down anymore. No js error what so ever.

    I should also mention that grid is still ajaxified and paging works fine. Actually, if I change page on the grid, ComboBox start working again as expected!?!

    They should be hooked, as I checked before and after and the init function is the same:

    Sys.Application.add_init(function() { 
        $create(Telerik.Web.UI.RadComboBox, .....

    I am suspecting that modifying the response headers is what causing all this, but it is surely acting strange and I think it should not have this behavior.

    **I have tried commenting the "Response.End();" but still same behavior.
  5. Konstantin Petkov
    Admin
    Konstantin Petkov avatar
    1911 posts

    Posted 02 May 2008 Link to this post

    Hi Oliver,

    The issue may also be caused by an incomplete AJAX settings. Do you use the RadAjaxManager to AJAX-enable that scenario? Please, make sure the RadComboBox is added as updated control as well.

    If you still need our assistance, I think the fastest way to resolve the problem would be to look at your exact source and debug it locally. Please, submit a regular support ticket sending a stripped-down working subset of your project. We will gladly look into it locally and advice you accordingly.

    Kind regards,
    Konstantin Petkov
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  6. Marty
    Marty avatar
    61 posts
    Member since:
    Oct 2008

    Posted 11 Mar 2009 Link to this post

    I'm having the same issue as Oliver here.

    I'm using the conditionalPostBack as follows:
    function conditionalPostback(sender, args) {  
                    if (args.EventTarget == '<%= ((Button)RadPanelBar1.FindItemByValue("SuppDocs").FindControl("btnUploadFiles")).UniqueID %>') {  
                        args.EnableAjax = false;  
                    }  
                } 

    to allow a full postback for a RadUploader that I have embedded in a RadPanelBar that is embedded in a RadAjaxPanel.  This works, however, after a full postback is performed, none of the comboboxes on the form work (exactly as Oliver described), the uploader loses all selection fields and the add/delete buttons no longer function.  The Ajax still works on the page, but the LoadingPanel I have set to display is no longer displayed during those calls.

    This is a content page in a master page setup.  For all of my pages, I use a RadAjaxManager on the master page, with a RadAjaxManagerProxy on each content page.  However, I could not use this setup on the page I'm referring to because I need to be able to set the conditional postback for the button I use to upload files through the RadUploader on this page.  So, I have the entire page in a RadAjaxPanel, as stated.  I tried the proxy setup on this page, setting the conditional postback in the AjaxManager on my masterpage, but this caused NONE of the scripts on all of my pages to funciton. 

    Beyond the issues mentioned w/the comboboxes and the RadLoading panel, this setup works fine...I'm wondering if this setup could perhaps have anything to do with the issue I'm experiencing and if Oliver ever found out what was causing his issue.

    I know it's a bit confusing, but would appreciate some insight from anybody.  I need to get this working soon.

    I'm using Q32008 latest version of the controls in .NET 3.5, Vista, VS2008.

    Thanks,
    Marty
  7. Iana Tsolova
    Admin
    Iana Tsolova avatar
    3388 posts

    Posted 13 Mar 2009 Link to this post

    Hello Marty,

    I suggest that you open a formal support ticket and send us a runnable sample illustrating your scenario. Thus I could check it out and see what could have gone wrong with it.

    Find more about uploading files with Ajax in the below online resources:
    http://demos.telerik.com/aspnet-ajax/ajax/examples/common/fileupload/defaultcs.aspx
    http://www.telerik.com/help/aspnet-ajax/upload_uploadingajax.html

    I hope this helps.

    All the best,
    Iana
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  8. Marty
    Marty avatar
    61 posts
    Member since:
    Oct 2008

    Posted 13 Mar 2009 Link to this post

    Hi again Lana,

    As I was creating a stripped down version of my app to submit in a ticket, I discovered that the behavior would not reproduce in a stripped down version... so, I spent some time trying to figure out the cause and it ended up being a java error in my code on the page that was causing this.  Once corrected, all is well.

    Again, I thank you for your dilligence and prompt replies.

    Marty
  9. Iana Tsolova
    Admin
    Iana Tsolova avatar
    3388 posts

    Posted 16 Mar 2009 Link to this post

    Hello Marty,

    I am happy to hear you found a resolution for your case.

    Do not hesitate to write if any issues arise.

    All the best,
    Iana
    the Telerik team


    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  10. Silvio Silva Junior
    Silvio Silva Junior avatar
    100 posts
    Member since:
    Mar 2010

    Posted 20 Feb 2014 in reply to Antoine Link to this post

    I had forgotten this code.

    Thanks
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017