Click here to Skip to main content
15,895,084 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
I use Print Helper to print panel
and on btn click my code is:

C#
protected void btnPrint_Click(object sender, EventArgs e)
{
    grd.AllowPaging=false;
    bindgrid();
    Session["ctrl"] = pnlPrint;
    ClientScript.RegisterStartupScript(this.GetType(), "onclick", "<script language=javascript>window.open('Print.aspx','PrintMe','height=500px,width=800px,scrollbars=1');</script>");
    grd.AllowPaging=true;
    bindgrid();
}

where pnlPrint is the id of aspPanel.



my Problem is that:
when click on print button the pagging is also displayed on the print page.
and only that page contents are printed on the paper
Posted
Updated 6-Aug-14 20:30pm
v3

When you enable paging on a web based application, only one page is on the client at any given time - it doesn't transfer the next page until the "next" button is instigated.

This means you cannot print more than one page by this method. You would need the page containing the grid to be refreshed to get all the data.
 
Share this answer
 
Comments
Kriti Sharma 10400841 7-Aug-14 6:59am    
so, what should i do for this???
please help...
use below code in print button click event


grd.AllowPaging = false;
     bindgrid();
      StringWriter sw = new StringWriter();
      HtmlTextWriter hw = new HtmlTextWriter(sw);
      grd.RenderControl(hw);
      string gridHTML = sw.ToString().Replace("\"", "'")
          .Replace(System.Environment.NewLine, "");
      StringBuilder sb = new StringBuilder();
      sb.Append("<script type = 'text/javascript'>");
      sb.Append("window.onload = new function(){");
      sb.Append("var printWin = window.open('', '', 'left=0");
      sb.Append(",top=0,width=1000,height=600,status=0');");
      sb.Append("printWin.document.write(\"");
      sb.Append(gridHTML);
      sb.Append("\");");
      sb.Append("printWin.document.close();");
      sb.Append("printWin.focus();");
      sb.Append("printWin.print();");
      sb.Append("printWin.close();};");
      sb.Append("</script>");
      ClientScript.RegisterStartupScript(this.GetType(), "GridPrint", sb.ToString());
      grd.AllowPaging = true;
      bindgrid();



and add below event also to CS Page

C#
public override void VerifyRenderingInServerForm(Control control)
{
    /* Verifies that the control is rendered */
}



If it solves your problem accept solution
 
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