You can use
Response.AddHeader("Content-disposition", "attachment; filename=" + Name);
Check out this example:
http://www.codeproject.com/KB/aspnet/textfile.aspx
This goes for ASP.NET. I am sure you can find similar solutions in all other server side languages. However there's no javascript solution to the best of my knowledge.