Click here to Skip to main content
15,893,588 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Please Friends.


I want to print specific data from asp.net page not full page like i want to print only two field from ten field.

and also i want to print same selected data on both side of page ...

Please tell me how can i do.


Please don't tell me to try my own or don't say follow link this is new for me and
i am trying this from 1 week huge pressure in office....

help me out.......

waiting for your reply.................
Posted

If you are not willing to try at your own or not follow a link with some guidelines, what exactly do you expect? Someone to write code for you?

Sorry, but the framing of your above point got me off-track. Please be considerate, people here are too having their own work and they help others because they like to help.

Anyway, in this case, either you need to open a separate page with data whatever you need to print and then use window.print().

Or as suggested at http://stackoverflow.com/questions/18323435/printing-an-asp-net-web-site-page[^]

You can then print content of particular element or with CSS3, follow the last answer.

Hope that helps
 
Share this answer
 
The easiest way to do, according to me, is to use a panel and put the controls(which you want to print) inside it. Use a button(outside the panel) like this
<asp:Button ID="Button2" runat="server" Text="Print" 
            OnClientClick = "return PrintPanel();" Enabled="False"/>

It has a javascript function OnClientClick which will do the printing job.
The javascript function for this will be
XML
<script type = "text/javascript">
        function PrintPanel() {
            var panel = document.getElementById("<%=Panel1.ClientID %>");
            var printWindow = window.open('', '', 'height=400,width=800');
            printWindow.document.write(panel.innerHTML);
            printWindow.document.close();
            setTimeout(function () {
                printWindow.print();
            }, 500);
            return false;
        }
    </script>

You may change it as per your requirement.
Hope this helps.. Happy Coding! :)
 
Share this answer
 

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