New to Telerik UI for ASP.NET AJAX? Download free 30-day trial

Download Files with Ajaxified Control

If you want to invoke download for a file from an AJAX-enabled control (either placed in RadAjaxPanelor ajaxified by RadAjaxManager ), you cannot use the normal response.WriteFile function.



Why? Because the XmlHttpRequest cannot handle this.

Instead you can use the ResponseScripts collection of the RadAjax controls to change the location header and download the file:

RadAjaxPanel1.ResponseScripts.Add(String.Format(@"window.location.href = ""{0}"";", ""));

RadAjaxPanel1.ResponseScripts.Add(String.Format("window.location.href = ""{0}"";", ""))

The ResponseScripts collection will be executed after ajax request completes.

See Also

In this article