Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I ran into same situation a while ago. I see you have already overridden following method. But did you put that method in your usercontrol? That will give you "no suitable method found to override". This method needs to be overridden in your .aspx.cs file where you will drop the usercontrol.</p> <p>Hers's code behind for UserControl that has ExportPdf() Method</p> <pre><code> protected void btnExportPdf_Click(object sender, EventArgs e) { System.Threading.Thread.Sleep(1000); ExportPdf(); } protected void ExportPdf() { using (StringWriter sw = new StringWriter()) { using (HtmlTextWriter hw = new HtmlTextWriter(sw)) { //To export all pages gvCharges.AllowPaging = false; this.BindRepeater(); gvCharges.RenderControl(hw); StringReader sr = new StringReader(sw.ToString()); Document pdfDoc = new Document(PageSize.A2, 10f, 10f, 10f, 0f); HTMLWorker htmlparser = new HTMLWorker(pdfDoc); PdfWriter.GetInstance(pdfDoc, Response.OutputStream); pdfDoc.Open(); htmlparser.Parse(sr); pdfDoc.Close(); Response.ContentType = "application/pdf"; Response.AddHeader("content-disposition", "attachment;filename=GridViewExport.pdf"); Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.Write(pdfDoc); Response.End(); } } } </code></pre> <p>Here's the source for .ascx file</p> <pre><code>&lt;asp:Button ID="btnExportPdf" runat="server" Text="Export to pdf" Visible = "false" onclick="btnExportPdf_Click" CssClass="btn btn-primary" /&gt; </code></pre> <p>Here's the source for .aspx where i dropped the usercontrol to</p> <pre><code> &lt;div class="form-section-body"&gt; &lt;table style="width: 100%"&gt; &lt;tr&gt; &lt;td colspan="2" style="padding: 20px 5px 5px 5px;"&gt; &lt;uc2:PosTrans ID="PosTrans1" runat="server" /&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/div&gt; </code></pre> <p>And here's the code behind .aspx.cs where i dropped the usercontrol to</p> <pre><code> namespace DFM.Dashboard { public partial class Dashboard : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } public override void VerifyRenderingInServerForm(Control control) { /* Verifies that the control is rendered */ } } </code></pre> <p>}</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload