Thursday, February 09, 2012 12:18 AM
My task is to pass the values of a List Item in a SharePoint list to a custom page which has special formatting to be able to print. There will be a link (called Print) on the DispForm.aspx page which when clicked will open up this custom page with the details of the list item.
This custom page will have a header section with the company logo etc, a footer with company address etc and the body will have the values of the list item in it.
Can someone please tell me how to go about doing this? I am using MOSS 2007.
Monday, February 13, 2012 11:36 AMModerator
Thursday, February 23, 2012 9:12 PM
Here are the steps I used to get the result you need. Note that I am using a button on my DispForm.aspx page - use this for now to make sure you can get this process to work:
- Created a new ASPX page called: PrintPage.aspx
- Added some text boxes to that page
- Created the following function to parse the query string value:
var url = window.location.toString();
var queryString = url.split("?");
var item1 = queryString.split("=");
document.getElementById("Text1").innerText = item1;
- I then call this function from the "body" onload event of PrintPage.aspx:
- Customized my list DispForm.aspx page with SharePoint Designer as follows:
- Added an Input Button just above the web part
- In the onclick event I call my custom function named: passValue()
<input name="btnHTML" type="button" value="HTML Button" onclick="passValue();" />
- Here is my passValue function:
var v1 = document.getElementById("SPFieldText").innerText; //"SPFieldText" field is the Title field
window.location="../../SitePages/PrintPage.aspx?p1=" + v1; //Nav to my print page passing the value in the Title field
When the DispForm.aspx page is loaded and the button clicked, the code gets the value in the "Title" field (SPFieldText), concatenates this to the URL as a query string and launches my print page. When the PrintPage.aspx page loads, it parses the query string and populates the value into first text box.
Let me know if this works for you!
Scott Heim - Microsoft Office InfoPath and SharePoint Designer Online Community Support
Tuesday, February 28, 2012 11:34 PM
Thanks for the solution above, it works nicely. I did make a few modifications to my Print Preview page and made use of a DataView Web Part, but you nailed it perfectly.
Saturday, October 13, 2012 1:23 PM
This is where it all gets so so confusing..
You said "Created a new ASPX page called: PrintPage.aspx"
But in Sharepoint designer, when looking at my shapepoint list (in Lists and libraries) there is no concept/place for "PAGE". There are 'Content Types', 'Views', 'Forms', 'Workflows' and 'Custom Actions'.
'File, Add Item' appears to have pages, but these seem to be master web-part pages creating new site-views etc, not a specific list item view.
But you specifically say 'Page'
I note you also call DispForm.aspx a 'Page', when as far as I can tell this is a 'Form'
Are 'Page' and 'Form' synonymous? how is one to tell when they are not.
Now please don't take it that I'm having a go at you, because I am not.
It's obvious that Yoshi understands enough to solve his problem.
I am trying to solve a similar issue and am getting lost in some of the 'assumptions' that are being made.