title: To print entire aspx page using C#
body: <p>I created a asp.net page containing labels grids etc.. it has </p>
  
  <p>code:</p>
  
  <pre><code>&lt;%@ Page Title="" Language="C#" MasterPageFile="~/App/MasterPage.master"  AutoEventWireup="true" CodeFile="ServiceCheckList.aspx.cs" Inherits="App_AutoRx_ServiceCheckList" %&gt;
  
  &lt;asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server"&gt;
  
  &lt;/asp:Content&gt;
  &lt;asp:Content ID="Content2" ContentPlaceHolderID="Content" runat="Server"&gt;
      &lt;div class="container"&gt;
          &lt;div class="row" style="box-shadow: 0px 1px 6px #808080 !important;"&gt;
              &lt;div class="panel"&gt;
                  &lt;div class="panel-heading"&gt;
                      &lt;h3 style="color: black;"&gt;Service Check List&lt;/h3&gt;
  
                      &lt;div style="text-align: right"&gt;
                          Date :
                          &lt;asp:Label ID="lblDate" runat="server"&gt;&lt;/asp:Label&gt;
                      &lt;/div&gt;
                  &lt;/div&gt;
                  &lt;div class="panel-body"&gt;
                      &lt;div&gt;
                          Service Check List Code :
                          &lt;asp:Label ID="lblSCLC" runat="server" Text="CSSC"&gt;&lt;/asp:Label&gt;
                      &lt;/div&gt;
                      &lt;table id="tblbase" class="nav-justified" border="1" style="border: thin inset #999999"&gt;
                          &lt;tr style="text-align: center; font-size: medium; color: #000000;"&gt;
                              &lt;td style="width: 35%; background-color: red; color: white"&gt;Customer Details&lt;/td&gt;
                              &lt;td style="width: 65%; background-color: red; color: white"&gt;Vehicle Details&lt;/td&gt;
                          &lt;/tr&gt;
                          &lt;tr&gt;
                              &lt;td&gt;
                                  &lt;div class="panel-body"&gt;
                                      &lt;table id="tblCustomer" class="nav-justified" style="column-width: inherit"&gt;
                                          &lt;tr&gt;
                                              &lt;td&gt;
                                                  &lt;asp:Label ID="lblForCustomerName" runat="server" Text="Customer Name:"&gt;&lt;/asp:Label&gt;&lt;/td&gt;
                                              &lt;td&gt;
                                                  &lt;asp:Label ID="lblCustomerName" runat="server" Text="Suraj"&gt;&lt;/asp:Label&gt;&lt;/td&gt;
                                          &lt;/tr&gt;
                                          &lt;tr&gt;
                                              &lt;td&gt;
                                                  &lt;asp:Label ID="lblForContactNo" runat="server" Text="Contact No:"&gt;&lt;/asp:Label&gt;&lt;/td&gt;
                                              &lt;td&gt;
                                                  &lt;asp:Label ID="lblContactNo" runat="server" Text="123456"&gt;&lt;/asp:Label&gt;&lt;/td&gt;
                                          &lt;/tr&gt;
                                          &lt;tr&gt;
                                              &lt;td&gt;
                                                  &lt;asp:Label ID="lblForAlternateNo" runat="server" Text="Alternate No:"&gt;&lt;/asp:Label&gt;&lt;/td&gt;
                                              &lt;td&gt;
                                                  &lt;asp:Label ID="lblAlternateNo" runat="server" Text="scc-101"&gt;&lt;/asp:Label&gt;&lt;/td&gt;
                                          &lt;/tr&gt;
                                          &lt;tr&gt;
                                              &lt;td&gt;
                                                  &lt;asp:Label ID="lblforEmailId" runat="server" Text="Email Id:"&gt;&lt;/asp:Label&gt;&lt;/td&gt;
                                              &lt;td&gt;
                                                  &lt;asp:Label ID="lblEmailId" runat="server" Text="scc-101"&gt;&lt;/asp:Label&gt;&lt;/td&gt;
                                          &lt;/tr&gt;
                                          &lt;tr&gt;
                                              &lt;td&gt;
                                                  &lt;asp:Label ID="lblforAddress" runat="server" Text="Address:"&gt;&lt;/asp:Label&gt;&lt;/td&gt;
                                              &lt;td&gt;
                                                  &lt;asp:Label ID="lblAddress"  runat="server" Text="scc-101"&gt;&lt;/asp:Label&gt;&lt;/td&gt;
                                          &lt;/tr&gt;
                                      &lt;/table&gt;
                                  &lt;/div&gt;
                              &lt;/td&gt;
                              &lt;td&gt;
                                  &lt;div class="panel-body"&gt;
                                      &lt;table id="tblvehicle" class="nav-justified" style="column-width: inherit"&gt;
                                          &lt;tr&gt;
                                              &lt;td&gt;
                                                  &lt;asp:Label ID="lblforRegistrationNo" runat="server" Text="Registration No:"&gt;&lt;/asp:Label&gt;&lt;/td&gt;
                                              &lt;td&gt;
                                                  &lt;asp:Label ID="lblRegistrationNo" runat="server" Text="XYZ"&gt;&lt;/asp:Label&gt;&lt;/td&gt;
                                              &lt;td&gt;
                                                  &lt;asp:Label ID="lblforVIN" runat="server" Text="VIN No:"&gt;&lt;/asp:Label&gt;&lt;/td&gt;
                                              &lt;td&gt;
                                                  &lt;asp:Label ID="lblVIN" runat="server" Text="XYZ"&gt;&lt;/asp:Label&gt;&lt;/td&gt;
                                          &lt;/tr&gt;
                                          &lt;tr&gt;
                                              &lt;td&gt;
                                                  &lt;asp:Label ID="lblforManufacturer" runat="server" Text="Manufacturer Name:"&gt;&lt;/asp:Label&gt;&lt;/td&gt;
                                              &lt;td&gt;
                                                  &lt;asp:Label ID="lblManufacturer" runat="server" Text="123456"&gt;&lt;/asp:Label&gt;&lt;/td&gt;
                                              &lt;td&gt;
                                                  &lt;asp:Label ID="lblforModel" runat="server" Text="Model Name:"&gt;&lt;/asp:Label&gt;&lt;/td&gt;
                                              &lt;td&gt;
                                                  &lt;asp:Label ID="lblModel" runat="server" Text="123456"&gt;&lt;/asp:Label&gt;&lt;/td&gt;
                                          &lt;/tr&gt;
                                          &lt;tr&gt;
                                              &lt;td&gt;
                                                  &lt;asp:Label ID="lblforFuelType" runat="server" Text="Fuel Type:"&gt;&lt;/asp:Label&gt;&lt;/td&gt;
                                              &lt;td&gt;
                                                  &lt;asp:Label ID="lblFuelType" runat="server" Text="scc-uefuvfu"&gt;&lt;/asp:Label&gt;&lt;/td&gt;
                                              &lt;td&gt;
                                                  &lt;asp:Label ID="lblforEnginesize" runat="server" Text="Engine Size:"&gt;&lt;/asp:Label&gt;&lt;/td&gt;
                                              &lt;td&gt;
                                                  &lt;asp:Label ID="lblEnginesize" runat="server" Text="scc-uefuvfu"&gt;&lt;/asp:Label&gt;&lt;/td&gt;
                                          &lt;/tr&gt;
                                          &lt;tr&gt;
                                              &lt;td&gt;
                                                  &lt;asp:Label ID="lblforEngineNo" runat="server" Text="Engine No:"&gt;&lt;/asp:Label&gt;&lt;/td&gt;
                                              &lt;td&gt;
                                                  &lt;asp:Label ID="lblEngineNo" runat="server" Text="scc-uefuvfu"&gt;&lt;/asp:Label&gt;&lt;/td&gt;
                                              &lt;td&gt;
                                                  &lt;asp:Label ID="lblforcolor" runat="server" Text="Color:"&gt;&lt;/asp:Label&gt;&lt;/td&gt;
                                              &lt;td&gt;
                                                  &lt;asp:Label ID="lblcolor" runat="server" Text="scc-uefuvfu"&gt;&lt;/asp:Label&gt;&lt;/td&gt;
                                          &lt;/tr&gt;
                                          &lt;tr&gt;
                                              &lt;td&gt;
                                                  &lt;asp:Label ID="lblforYearBuild" runat="server" Text="Year of build:"&gt;&lt;/asp:Label&gt;&lt;/td&gt;
                                              &lt;td&gt;
                                                  &lt;asp:Label ID="lblYearBuild" runat="server" Text="scc-uefuvfu"&gt;&lt;/asp:Label&gt;&lt;/td&gt;
                                          &lt;/tr&gt;
                                      &lt;/table&gt;
                                  &lt;/div&gt;
                              &lt;/td&gt;
                          &lt;/tr&gt;
                      &lt;/table&gt;
                  &lt;/div&gt;
                  &lt;div class="panel-body"&gt;
                      &lt;div class="heading"&gt;
                          &lt;h4&gt;Items Details&lt;/h4&gt;
                      &lt;/div&gt;
                      &lt;table id="tblItems" class="nav-justified" border="1" style="border: thin inset #999999"&gt;
                          &lt;tr style="text-align: center; font-size: medium; color: #000000;"&gt;
                              &lt;td style="width: 33%; background-color: red; color: white"&gt;Services&lt;/td&gt;
                              &lt;td style="width: 33%; background-color: red; color: white"&gt;Spare Parts&lt;/td&gt;
                              &lt;td style="width: 33%; background-color: red; color: white"&gt;Tachnician &lt;/td&gt;
                          &lt;/tr&gt;
                          &lt;tr&gt;
                              &lt;td style="width: 33%"&gt;
                                  &lt;asp:GridView ID="gvServices" runat="server"&gt;&lt;/asp:GridView&gt;
                              &lt;/td&gt;
                              &lt;td style="width: 33%"&gt;
                                  &lt;asp:GridView ID="gvSpare" runat="server"&gt;&lt;/asp:GridView&gt;
  
                              &lt;/td&gt;
                              &lt;td style="width: 33%"&gt;
                                  &lt;asp:GridView ID="gvTech" runat="server"&gt;&lt;/asp:GridView&gt;
  
                              &lt;/td&gt;
                          &lt;/tr&gt;
                      &lt;/table&gt;
                  &lt;/div&gt;
                  &lt;div class="panel-body"&gt;
                      &lt;div class="heading"&gt;
                          &lt;h4&gt;Office Use Only&lt;/h4&gt;
                      &lt;/div&gt;
                      &lt;table class="nav-justified" border="1" style="border: thin inset #999999"&gt;
                          &lt;tr style="text-align: center; font-size: medium; color: #000000;"&gt;
                              &lt;td style="width: 100%; background-color: red; color: white"&gt;Office Use&lt;/td&gt;
  
                          &lt;/tr&gt;
                          &lt;tr style="text-align:justify; font-size: medium; color: #000000;"&gt;
                              &lt;td style="width: 100%"&gt;
                                  &lt;div&gt;
                                      uiuiht8d7yjgnjgixtixjtn
                                  &lt;/div&gt;
                              &lt;/td&gt;
                          &lt;/tr&gt;
                          &lt;tr style="text-align: center; font-size: medium; color: #000000;"&gt;
                              &lt;td style="width: 100%"&gt;
                                  &lt;div style="text-align: left"&gt;
                                      Address :
                                      &lt;asp:Label ID="lblOfficeAddress" runat="server" Text="office adress"&gt;&lt;/asp:Label&gt;
                                  &lt;/div&gt;
  
                              &lt;/td&gt;
  
                          &lt;/tr&gt;
                      &lt;/table&gt;
  
                  &lt;/div&gt;
                  &lt;div class="panel-body"&gt;
                      &lt;p style="text-align: justify"&gt;I hereby authorize the above repair work to be done along with the necessary material, and hereby grant you and/or your empoyees permission to operate the car, truck or vechicle herein described on streets, highways or elsewhere for the purpose of testing and/or inspection. An express mechanic's lien is hereby acknowledged on above car, truck or vehicle to secure the amount of repair thereto.&lt;/p&gt;
                      &lt;div&gt;
  
                          &lt;table class="nav-justified" style="color: black; font-size: medium;"&gt;
                              &lt;tr&gt;
                                  &lt;td&gt;Work Authorized By:____________________&lt;/td&gt;
                                  &lt;td style="text-align: right"&gt;Date Promised:
                                      &lt;asp:Label ID="lblDatePromised" runat="server" Text="x/xx/2222"&gt;&lt;/asp:Label&gt;&lt;/td&gt;
                              &lt;/tr&gt;
                              &lt;tr&gt;
                                  &lt;td&gt;Delivered To:____________________&lt;/td&gt;
                                  &lt;td style="text-align: right"&gt;Date Delivered:
                                      &lt;asp:Label ID="lblDateDelivered" runat="server" Text="x/xx/2222"&gt;&lt;/asp:Label&gt;&lt;/td&gt;
                              &lt;/tr&gt;
                          &lt;/table&gt;
  
                      &lt;/div&gt;
                  &lt;/div&gt;
              &lt;/div&gt;
          &lt;/div&gt;
          &lt;asp:LinkButton ID="LinkButton1"  runat="server" OnClick="LinkButton1_Click"&gt;LinkButton&lt;/asp:LinkButton&gt;
      &lt;/div&gt;
  
  
  &lt;/asp:Content&gt;
  </code></pre>
  
  <p>I wants to print this page but when i use window.print(); it gives some different o/p it does not includes css effects as well header and footer which came from master are also not in formats...
  thank you....!!!!</p>
  
  <p>expected o/p
  <img src="https://i.stack.imgur.com/mZQ7G.png" alt="enter image description here"></p>
  
  <p>getting
  <img src="https://i.stack.imgur.com/wHXFa.png" alt="enter image description here"></p>