Employers - Post Free Jobs
Forum guidelines
AuthorQuestion
Printing a ListView from a web page
Posted on: 25 Feb 2010

Hi,
I am trying to print a listview from a web page. It is not a Windows forms listview. Even though the webpage contains many other controls, I am interested in printing only the listview with its items. Could you please let me know how to do this?
Thanks and Regards,
Mohan

A man is great by deeds, not by birth
AuthorReply
Sam Hobbs
  • 0
  • 0
accepted
Re: Printing a ListView from a web page
Posted on: 25 Feb 2010   Accepted Answer
See my article Introduction to Web Site Scraping.
Thinking is a feeling; pleasant for some and unpleasant for others.
Re: Printing a ListView from a web page
Posted on: 25 Feb 2010  
Hi,

  Using javascript you can do this. Since it is easy to implement.

function CallPrint(strid)
{
            var prtContent = document.getElementById(strid);
            var WinPrint = window.open('', '', 'letf=0,top=0,width=1,height=1,toolbar=0,scrollbars=0,status=0');
            WinPrint.document.write(prtContent.innerHTML);
            WinPrint.document.close();
            WinPrint.focus();
            WinPrint.print();
            WinPrint.close();
        }

This will get the entire listview control and put it inside a new window with all the data This can be used for any control. And on a button click call the javascript.

 <asp:button ID="btnPrint" OnClientClick="CallPrint('divPrint')" Text="JavaScript" Runat="Server" />

Here i have a passed the div which holds the Listview control.

Hope this could help you.

Regards,
raaj

----------------------------------------------------
Please mark as Answer if it resolves your problem

Re: Printing a ListView from a web page
Posted on: 01 Mar 2010  

Hi Raaj,
Thank you. It worked for me.
Regards,
Mohan

A man is great by deeds, not by birth
Employers - Post Free Jobs

SPONSORED BY

Offshore Software and Database Development
MCN is your source for developing solutions involving websites, mobile apps, cloud-computing, databases, BI, back-end services and processes and client-server applications.