HI
I have an invoice web form in which the invoice preview created as div which includes images for header also. Can we export this div portion to pdf or word pad inorder email .Or if anyother suggessions please reply
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Manoj BhoirRank #599 · 4K reputationPosted Jun 13, 2015, 11:19 PM EDT
Make div run at server:
Then do it like this:
using System.IO;
using System.Text;
using System.Net.Mail;
private string DivToHtml(HtmlGenericControl hgc)
protected void SendMailButton_Click(object sender, EventArgs e){
StringBuilder sb = new StringBuilder();
StringWriter sw = new StringWriter(sb);
HtmlTextWriter hw = new HtmlTextWriter(sw);
hgc.RenderControl(hw);
return sb.ToString();
}
{
MailMessage mail = new MailMessage();
mail.Body = DivToHtml(Div4); // Or here you can use Div4.InnerHTML
mail.IsBodyHtml = true;
//......
}