Take a look at WebFile. There’s an example under the “Download” method that will do just that. Just change the line TextFile.Data = "Hello, world!", or you can utilize the first example on the WebFile page.
I needed to change the first line of the code in the example because it was not compiling.
This is my code
Dim TextFile as New WebFile // "TextFile As WebFile" is a property of the web page
TextFile.MimeType = "text/plain"
TextFile.ForceDownload = True // If False, the browser may try to display the file instead of download it
TextFile.FileName = "TextFile.txt"
TextFile.Data = "Hello, world!"
ShowURL(TextFile.URL) // This causes the file to be downloaded
I will replace TextFile.Data with TextArea1.textt when I make the code from the example work.
Try setting “TextFile” as a property of your window or container control instead of instantiating it in code. I think the problem you’re having is the variable “TextFile” is going out of context and therefore doesn’t exist as soon as the method quits so the user’s browser is unable to find it.