0

I have a div class:-

<div class="hidden">
This is it.
       <asp:Button ID="Button1" runat="server" 
        Height="23px" style="margin-top: 0px" Width="69px" text="Print" OnClientClick="PrintElem('#hidden'); return false;"/>
</div>

inside this div class, a list of elements that are dynamically populated. I am trying to use a print button inside this div class to print all elements.

function PrintElem(elem) {
            Popup($(elem).html());
        }

        function Popup(data) {
            var mywindow = window.open('', '#hidden', 'height=400,width=600');
            mywindow.document.write('<html><head><title>Pharmacy List</title>');
            /*optional stylesheet*/ //mywindow.document.write('<link rel="stylesheet" href="main.css" type="text/css" />');
            mywindow.document.write('</head><body >');
            mywindow.document.write(data);
            mywindow.document.write('</body></html>');

            mywindow.print();
            mywindow.close();

           return true;
        }

This works great, except the page that is printed out is blank and titled 'undefined'.

2 Answers 2

1

OnClientClick="PrintElem('#hidden') you're trying to print an element with an id of hidden NOT a class of hidden.

0
0

In your code above #hidden is for id="hidden" whereas .hidden would need to be used for class="hidden"

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.