paradise_wolf
04-01-2007, 07:27 PM
It seems that the download dialog triggered by this code
prevents the label control “Label2” to show its message.
What should I change/add to this code in order that the
"path" could appear in the web page in the
“Label2” control ?
Here is the relevant code:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
protected void DownlFile_Click(object sender, EventArgs e)
{
string web_path = "./items/X-103.pdf";
string path = Server.MapPath(web_path);
Label2.Text = path;
FileStream MyFileStream = new FileStream(path, FileMode.Open);
long FileSize;
FileSize = MyFileStream.Length;
byte[] Buffer = new byte[(int)FileSize];
MyFileStream.Read(Buffer, 0, (int)MyFileStream.Length);
MyFileStream.Close();
Response.ContentType = "application/pdf";
Response.AddHeader
("content-disposition", "attachment; filename= X-103.pdf");
Response.BinaryWrite(Buffer);
}
<asp:Button ID="DownlFile" runat="server" Text="Download The File"
OnClick="DownlFile_Click" />
<br /> <br />
<asp:Label ID="Label2" runat="server" Text=""></asp:Label>
prevents the label control “Label2” to show its message.
What should I change/add to this code in order that the
"path" could appear in the web page in the
“Label2” control ?
Here is the relevant code:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
protected void DownlFile_Click(object sender, EventArgs e)
{
string web_path = "./items/X-103.pdf";
string path = Server.MapPath(web_path);
Label2.Text = path;
FileStream MyFileStream = new FileStream(path, FileMode.Open);
long FileSize;
FileSize = MyFileStream.Length;
byte[] Buffer = new byte[(int)FileSize];
MyFileStream.Read(Buffer, 0, (int)MyFileStream.Length);
MyFileStream.Close();
Response.ContentType = "application/pdf";
Response.AddHeader
("content-disposition", "attachment; filename= X-103.pdf");
Response.BinaryWrite(Buffer);
}
<asp:Button ID="DownlFile" runat="server" Text="Download The File"
OnClick="DownlFile_Click" />
<br /> <br />
<asp:Label ID="Label2" runat="server" Text=""></asp:Label>