Sign In| Join
Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Member
476 Points
441 Posts
Feb 06, 2011 02:22 PM|LINK
i found this useful code:
01.public override void VerifyRenderingInServerForm(Control control) 02. { 03. 04. /* Verifies that the control is rendered */ 05. 06. } 07. 08. 09.protected void imgbtnpdf_Click(object sender, ImageClickEventArgs e) 10. { 11. 12. 13. Response.ContentType = "application/pdf"; 14. 15. Response.AddHeader("content-disposition", 16. 17. "attachment;filename=GridViewExport.pdf"); 18. 19. Response.Cache.SetCacheability(HttpCacheability.NoCache); 20. 21. StringWriter sw = new StringWriter(); 22. 23. HtmlTextWriter hw = new HtmlTextWriter(sw); 24. 25. GridView2.AllowPaging = false; 26. 27. GridView2.DataBind(); 28. 29. GridView2.RenderControl(hw); 30. 31. StringReader sr = new StringReader(sw.ToString()); 32. 33. iTextSharp.text.Document pdfDoc = new iTextSharp.text.Document(iTextSharp.text.PageSize.A4, 10f, 10f, 10f, 0f); 34. 35. HTMLWorker htmlparser = new HTMLWorker(pdfDoc); 36. 37. PdfWriter.GetInstance(pdfDoc, Response.OutputStream); 38. 39. pdfDoc.Open(); 40. 41. htmlparser.Parse(sr); 42. 43. pdfDoc.Close(); 44. 45. Response.Write(pdfDoc); 46. 47. Response.End(); 48. 49.
and i'm getting this error RegisterForEventValidation can only be called during Render();
i cant disable validation method at page drectives, so how can i solve this? where is the bug here?.....i use itextsharp 5.0.5
This will export the gridview with the associated images?
hsl89
Member
476 Points
441 Posts
create pdf
Feb 06, 2011 02:22 PM|LINK
i found this useful code:
01.public override void VerifyRenderingInServerForm(Control control) 02. { 03. 04. /* Verifies that the control is rendered */ 05. 06. } 07. 08. 09.protected void imgbtnpdf_Click(object sender, ImageClickEventArgs e) 10. { 11. 12. 13. Response.ContentType = "application/pdf"; 14. 15. Response.AddHeader("content-disposition", 16. 17. "attachment;filename=GridViewExport.pdf"); 18. 19. Response.Cache.SetCacheability(HttpCacheability.NoCache); 20. 21. StringWriter sw = new StringWriter(); 22. 23. HtmlTextWriter hw = new HtmlTextWriter(sw); 24. 25. GridView2.AllowPaging = false; 26. 27. GridView2.DataBind(); 28. 29. GridView2.RenderControl(hw); 30. 31. StringReader sr = new StringReader(sw.ToString()); 32. 33. iTextSharp.text.Document pdfDoc = new iTextSharp.text.Document(iTextSharp.text.PageSize.A4, 10f, 10f, 10f, 0f); 34. 35. HTMLWorker htmlparser = new HTMLWorker(pdfDoc); 36. 37. PdfWriter.GetInstance(pdfDoc, Response.OutputStream); 38. 39. pdfDoc.Open(); 40. 41. htmlparser.Parse(sr); 42. 43. pdfDoc.Close(); 44. 45. Response.Write(pdfDoc); 46. 47. Response.End(); 48. 49.and i'm getting this error RegisterForEventValidation can only be called during Render();
i cant disable validation method at page drectives, so how can i solve this? where is the bug here?.....i use itextsharp 5.0.5
This will export the gridview with the associated images?