G
Guest
Hello,
I need to write an asp.net page that pushes a files to the user for download.
The code I wrote works just fine, in that it sends a file to the user. But
the HTML controls on the page are not updated..
private void Button1_Click(object sender, System.EventArgs e)
{
//part 1
TextBox3.Text = TextBox1.Text + " " + TextBox2.Text;
TextBox1.Visible = TextBox2.Visible = TextBox3.Visible = false;
TextBox1.Visible = TextBox2.Visible = TextBox3.Visible = true;
Label1.Text = "Thank you for choosing this program.";
//part 2
System.IO.FileInfo info = new
System.IO.FileInfo(System.Web.HttpContext.Current.Server.MapPath(".") + "\\"
+ "txt.txt");
HttpContext.Current.Response.ClearHeaders();
HttpContext.Current.Response.ClearContent();
HttpContext.Current.Response.ContentType = "";
HttpContext.Current.Response.AppendHeader("Content-Disposition:","
attachment; filename=txt.txt");
HttpContext.Current.Response.AppendHeader("Contect-Length", "100");
HttpContext.Current.Response.Charset="UTF-8";
HttpContext.Current.Response.WriteFile("txt.txt");
HttpContext.Current.Response.Flush();
HttpContext.Current.Response.Close();
}
The second part of the code above, the Response object sends the file down
to the user, but the first part of code does not work. Is there a way to get
both to work?
Thanks in advance,
I need to write an asp.net page that pushes a files to the user for download.
The code I wrote works just fine, in that it sends a file to the user. But
the HTML controls on the page are not updated..
private void Button1_Click(object sender, System.EventArgs e)
{
//part 1
TextBox3.Text = TextBox1.Text + " " + TextBox2.Text;
TextBox1.Visible = TextBox2.Visible = TextBox3.Visible = false;
TextBox1.Visible = TextBox2.Visible = TextBox3.Visible = true;
Label1.Text = "Thank you for choosing this program.";
//part 2
System.IO.FileInfo info = new
System.IO.FileInfo(System.Web.HttpContext.Current.Server.MapPath(".") + "\\"
+ "txt.txt");
HttpContext.Current.Response.ClearHeaders();
HttpContext.Current.Response.ClearContent();
HttpContext.Current.Response.ContentType = "";
HttpContext.Current.Response.AppendHeader("Content-Disposition:","
attachment; filename=txt.txt");
HttpContext.Current.Response.AppendHeader("Contect-Length", "100");
HttpContext.Current.Response.Charset="UTF-8";
HttpContext.Current.Response.WriteFile("txt.txt");
HttpContext.Current.Response.Flush();
HttpContext.Current.Response.Close();
}
The second part of the code above, the Response object sends the file down
to the user, but the first part of code does not work. Is there a way to get
both to work?
Thanks in advance,