This is a migrated thread and some comments may be shown as answers.

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

8 Answers 376 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Antoine
Top achievements
Rank 1
Antoine asked on 01 May 2008, 05:23 AM
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!

8 Answers, 1 is accepted

Sort by
0
Konstantin Petkov
Telerik team
answered on 01 May 2008, 07:41 AM
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
0
Antoine
Top achievements
Rank 1
answered on 01 May 2008, 03:46 PM
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.
0
Konstantin Petkov
Telerik team
answered on 02 May 2008, 07:08 AM
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
0
Marty
Top achievements
Rank 1
answered on 11 Mar 2009, 02:48 PM
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
0
Iana Tsolova
Telerik team
answered on 13 Mar 2009, 11:11 AM
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.
0
Marty
Top achievements
Rank 1
answered on 13 Mar 2009, 07:57 PM
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
0
Iana Tsolova
Telerik team
answered on 16 Mar 2009, 02:02 PM
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.
0
Silvio Silva Junior
Top achievements
Rank 2
answered on 21 Feb 2014, 03:24 AM
I had forgotten this code.

Thanks
Tags
Ajax
Asked by
Antoine
Top achievements
Rank 1
Answers by
Konstantin Petkov
Telerik team
Antoine
Top achievements
Rank 1
Marty
Top achievements
Rank 1
Iana Tsolova
Telerik team
Silvio Silva Junior
Top achievements
Rank 2
Share this question
or