| re: Download file
Hey Brian,
thanks for the help. But it doesnt work correctly for
me. I have some probs with the code. Here is what I tried:
Dim tTitlew as new StringWriter()
Try
' loop ...
Dim iLoop as integer
For iLoop = 0 To ...
Dim str as String = ...
tTitlew.Write(strLink)
next
Response.ContentType = "application/text/HTML"
Dim hTitlew as new HtmlTextWriter(tTitlew)
Label1.RenderControl(hTitlew)
Response.Write(tTitlew.ToString())
....
When this part executes, it tries to download my aspx page
instead of the memory one. Can you tell me what i am doing
wrong?
Thanks[color=blue]
>-----Original Message-----
>Vishal,
>
>One way to accomplish this is
>1) change the content type to what the file represents[/color]
(e.g. Excel, Word,[color=blue]
>etc..)
>2) create file in memory and populate it with data
>3) write it out to the browser
>If they are using a recent version of IE they may not get[/color]
the download[color=blue]
>dialog box but the file will display directly in the[/color]
browser. The user can[color=blue]
>then go to File->Save As.. and save the file however they[/color]
want. I have[color=blue]
>posted a sample for you below.
>
>Hope this helps.
>-----------------------------
>using System;
>....
>using System.IO;
>
>Response.ContentType = "application/vnd.ms-excel";
>Label1.Text = DateTime.Now.ToString();
>StringWriter tTitlew = new StringWriter();
>HtmlTextWriter hTitlew = new HtmlTextWriter(tTitlew);
>Label1.RenderControl(hTitlew);
>Response.Write(tTitlew.ToString());
>.
>[/color] |