Wednesday, September 21

Print a page without showing some control like button


<script type="text/javascript">
  function CallPrint(strid)
  {
      var prtContent = document.getElementById(strid);
      var WinPrint = window.open('','','letf=0,top=0,width=400,height=400,toolbar=0,scrollbars=0,status=0');
      WinPrint.document.write(prtContent.innerHTML);
      WinPrint.document.close();
      WinPrint.focus();
      WinPrint.print();
      WinPrint.close();
 
}
  </script>
<script type="text/javascript" language="javascript">
    function Print(DivPrint)
    {
            document.getElementById("<%=btn_Print.ClientID%>").hidden=true;
            document.getElementById("<%=btn_Exit.ClientID%>").hidden=true;
 
    window.print();
 
    document.getElementById("<%=btn_Exit.ClientID%>").hidden=false;

 
    }
    </script>
   <asp:Button ID="btn_Print" runat="server"  Text="Print" Width="84px"
                              BackColor="#339933"  ForeColor="White" OnClientClick="Print(DivPrint);" />


without writing java script

 <asp:Button ID="btn_Print" runat="server"  Text="Print" Width="84px"
                              BackColor="#339933"  ForeColor="White" OnClientClick="btn_Print.hidden=true;btn_Any.hidden=true;otherControlID.hidden=true;window.print();" />


it prints all data inside a page except the hidden controls.

1 comment:

  1. in my point of view its very simple to get the proper idea about printing a page

    ReplyDelete

Please don't spam, spam comments is not allowed here.

.

ShibashishMnty
shibashish mohanty