Edit this page

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.


Response.WriteFile("~/Your_File");

Response.WriteFile("~/Your_File")

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}"";", "http://yoursite.com/Your_File"));

RadAjaxPanel1.ResponseScripts.Add(String.Format("window.location.href = ""{0}"";", "http://yoursite.com/Your_File"))

The ResponseScripts collection will be executed after ajax request completes.

See Also