.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Articles >> SharePoint >> Post New Resource Bookmark and Share   

 Subscribe to Articles

Printing data from WSS (list)

Posted By:Sasi Prabhu       Posted Date: October 31, 2011    Points: 200    Category: SharePoint    URL: http://www.dotnetspark.com  

Print data in SharePoint
 


Try the following steps. It works for most web parts (i have used this for lists)

1. Start with a web part You start by having a web part with a display of information, such as a list.
If you don't have one already you can start by creating a SharePoint Event List, and then, adding a Calendar web part (remember to choose the Calendar View).
2. Add the Print Button You will be adding a Print Button to the page, by putting the JavaScript below
into a Content Editor Web Part.
Add a Content Editor Web Part to the page with the web part you want to print.
Open its properties and click the Source Code button to add the JavaScript code.
Copy the following code directly into the Text Builder box. This code will create a "Print Web Part" button that when clicked, will execute the print action.


value="Print Web Part">




3. Connect the Print Button to the Web Part
To do this we need the
tag ID for the Web Part we want to print, then, we modify the ID in the JavaScript of the Print Button.
To find out the ID of the Web Part we want to print:
Using your browser, right mouse click on the page where the Web Part is installed and choose "View Source". This will open a view of your page in HTML within Notepad.

Press CTRL-F, to initiate a Find. Enter the Title of your Web Part. You may need to execute a find a couple of times as your navigation may show "Events" as well.

Once you have located the HTML for your Web Part for example;

"
",

look later in the HTML for a
tag which matches the Web Part Queue Number, in this case WPQ6. In our case it looks like

"

The "WebPartWPQ6" would be the ID we want. The key part of the ID is to know if it is 1, 2, 3, etc. Here it is 6.

To modify the Print Button JavaScript:
Modify the Content Editor Web Part which contains the JavaScript you pasted earlier and go into the Source View.
Look for the line "//Controls which Web Part or zone to print", the line underneath controls the ID near the top.
Replace the "WebPartWPQ6" with the ID you copied from the source of the page andclick "OK".
Save the changes and click OK.



4. Print the Web Part Content
We are now ready to test what you have labored to create. Once the page has been refreshed inside of Internet Explorer, click on the "Print Web Part"button. You should see a new Window with the content of your web part.
If your pop-up blocker IS NOT turned on, you will get the Print Dialogue.
If it is turned on, then you can go to File Print or Print Preview.
Now, print the content.



 Subscribe to Articles

     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend