Search code examples
asp.netprintingweb-controlsprinting-web-page

Hide header and footer while printing a webcontrol using ASP.NET


How can I hide the header like 'Page 1 of 1' and footer (url) when printing a webcontol in ASP.NET?

I currently doing by opening a new page on Print button click ande in it

protected void Page_Load(object sender, EventArgs e)
{
    if( null != Session["Control"] )
    {
        Control ctrl = ( Control )Session["Control"];
        PrintManager.PrintWebControl( ctrl );
        Session["Control"] = null;
    }
}

This will print the header and footer. How to avoid it?


Solution

  • That setting is configured by the user in their browser. Their is no way to disable it from code. You'r best bet is to include instructions on how to configure/disable the settings.

    See an example here: http://www.xheo.com/products/sps/default.aspx?print=true