none
Pass list values to custom page for printing

    Question

  • Hello

    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.

    Thank you.

    Yoshi

    Thursday, February 09, 2012 12:18 AM

Answers

  • Hi Yoshi,

    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:

    <script type="text/javascript">
    function GetValues()
    {
         var url = window.location.toString();
         var queryString = url.split("?");
         var item1 = queryString[1].split("=");
         document.getElementById("Text1").innerText = item1[1];
    }
    </script>

         - I then call this function from the "body" onload event of PrintPage.aspx:

    <body onload="GetValues()">

    - 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:

    <script type="text/javascript">
    function passValue()
    {
         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
    }
    </script>

    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


    Scott Heim - Microsoft Office InfoPath and SharePoint Designer Online Community Support

    • Proposed as answer by Scott He - MSFT Thursday, February 23, 2012 9:12 PM
    • Marked as answer by SharePointYo Tuesday, February 28, 2012 11:33 PM
    Thursday, February 23, 2012 9:12 PM

All replies

  • Hi Yoshi,

    I am trying to involve someone familiar with this topic to further look at this issue. There might be some time delay. Appreciate your patience.

    Thanks


    Daniel Yang

    TechNet Community Support

    Monday, February 13, 2012 11:36 AM
    Moderator
  • Hi Yoshi,

    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:

    <script type="text/javascript">
    function GetValues()
    {
         var url = window.location.toString();
         var queryString = url.split("?");
         var item1 = queryString[1].split("=");
         document.getElementById("Text1").innerText = item1[1];
    }
    </script>

         - I then call this function from the "body" onload event of PrintPage.aspx:

    <body onload="GetValues()">

    - 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:

    <script type="text/javascript">
    function passValue()
    {
         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
    }
    </script>

    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


    Scott Heim - Microsoft Office InfoPath and SharePoint Designer Online Community Support

    • Proposed as answer by Scott He - MSFT Thursday, February 23, 2012 9:12 PM
    • Marked as answer by SharePointYo Tuesday, February 28, 2012 11:33 PM
    Thursday, February 23, 2012 9:12 PM
  • Hi Scott

    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.

    Cheers,

    Yoshi.

    Tuesday, February 28, 2012 11:34 PM
  • Hi Scot.

    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.

    Thanks

    David

    Saturday, October 13, 2012 1:23 PM