Click here to Skip to main content
15,888,351 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
ASP.NET
<pre><asp:Button ID="btnGetSelected" runat="server" Text="Get selected records" OnClick="btnGetSelected_Click" />
         <asp:CustomValidator ID="CustomValidator1" runat="server" Style=" font-size:x-large" ErrorMessage="Please select at least one record." 
    ClientValidationFunction="Validate" ForeColor="Red"></asp:CustomValidator>
      
        <asp:Button ID="ButtonHdn" runat="server" Text="Button" Style="display: none;"  />
        </center>
          
        <cc1:ModalPopupExtender ID="modalpop1" runat="server" PopupControlID="Panel1" TargetControlID="ButtonHdn"  dynamicservicepath=""
                enabled="True"
                 BackgroundCssClass="modalBackground">
        </cc1:ModalPopupExtender>
        <asp:Panel ID="Panel1" runat="server" CssClass="modalPopup" align="center" style="max-height: 500px; overflow: auto; display:none; ">
               <asp:Button ID="btnClose" runat="server" Text="Close" OnClick="btnClose_Click" />
          <asp:Button ID="Btbprint" runat="server" Text="Print" OnClientClick="printGrid()" />
          
                <table id="table1" runat ="server" >
                <tr>
                <td>
             <asp:Literal ID="Literal1" runat="server"></asp:Literal>
                     </td>
                </tr>
                    
                    </table>
     
</asp:Panel>
        </ContentTemplate>
    </asp:UpdatePanel>

</div>



Print function javascript:-


function printGrid() {
    var printContent = document.getElementById('<%= table1.ClientID %>');
    var windowUrl = 'about:blank';
    var uniqueName = new Date();
    var windowName = 'Print' + uniqueName.getTime();
    var printWindow = window.open(windowUrl, windowName, 'left=50000,top=50000,width=0,height=0');


    printWindow.document.write(printContent.innerHTML);
    printWindow.document.close();
    printWindow.focus();
    printWindow.print();
    printWindow.close();

}


What I have tried:

when click print button(inside panel) modalpop extender automatically hide 
Posted

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