Click here to Skip to main content
15,900,258 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I try to use this code but this code does not work with images , just with text.

try
{
Response.Clear();
Response.AddHeader("content-disposition", "attachment;filename=" + ViewState["fileName"].ToString() + ".doc");
Response.Charset = "";
Response.Buffer = true;
EnableViewState = false;

Response.ContentType = "application/vnd.word";
System.IO.StringWriter stringWrite = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
Panel1.RenderControl(htmlWrite);
Response.ContentEncoding = System.Text.Encoding.UTF8;
Response.Write(stringWrite.ToString());
Response.End();
}
catch (Exception ex)
{
Response.Write(ex.Message);
}

but this code does not work with images , just with text.
Posted

1 solution

The path you mentioned for the images in your html/aspx page should be absolute like
http://somepage.com/abc.png instead of ~/abc.png.
replace the path with Absolute URL and hope it works fine
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900