RaisKazi: Thanks for your post. Checked but it is not the case. As mentioned in my inital post, I transplaned the exact the same code from another aspx. file (in the same project). Another one works fine. Somethin is stranger to me.
I re-checked my code in both aspx (1 works well but another 1 not). The code for the one working well is below:
<asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="~/Images/PDF.jpg"
onclick="ImageButton1_Click" style="height: 16px"/>
and the code behind:
protected void ImageButton1_Click(object sender, ImageClickEventArgs e) {
WebClient client = new WebClient();
Byte[] buffer = client.DownloadData(path);
Response.ContentType = "application/pdf";
Response.AddHeader("content-length", buffer.Length.ToString());
Response.BinaryWrite(buffer);
}
The one does not working likes that below:
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server"/>
<asp:updatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:PlaceHolder runat="server" ID="placeholder1"/>
</ContentTemplate>
</asp:updatePanel>
</div>
The code behind runs the same code in the method:
public void imageBtn_Click(object sender, ImageClickEventArgs e) {
......
string pdfPath = g.sFolder + myPdf;
WebClient client = new WebClient();
Byte[] buffer = client.DownloadData(pdfPath);
Response.ContentType = "application/pdf";
Response.AddHeader("content-length", buffer.Length.ToString());
Response.BinaryWrite(buffer);
}
How can this problem be solved? Thanks if you can provide your hint.