This topic is locked

Master Data on Print/Export

12/6/2004 3:36:41 PM
ASPRunnerPro General questions
D
dheydt author

Is there an easy way to include Master Table information on the Printer Friendly page?
Also, can this information be easily included in the output produced by the Export page?
Thanks,

Dan

Sergey Kornilov admin 12/7/2004

Dan,
adding master table info on the printer-friendly page sounds like a nice idea. I will add this feature in the next ASPRunnerPro version.
Meanwhile you can take a look into DisplayMasterTableInfo function that displays master table info on the list page.

D
dheydt author 12/7/2004

Thanks Sergey. I followed your advice and took a look at the DisplayMasterTableInfo function and have come up with a work-around solution. I'm going to post it here for anyone else that may want to do the same thing.
First I made an assumption that the printer-friendly page would always be called from the list.asp page. So I modified the list.asp page to pass the Master Header to the print.asp page through a session variable.
I modified the three files variables.asp, list.asp, and print.asp as follows...
In variables.asp I created a global variable to indicate wether I wanted the header to appear or not. This may not be necessary but I wanted to have a way to shut-off the header if I later decided I didn't want it.
This is the code I added to Variables.asp

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

gstrMasterOnPrint = "Y"    'global flag to indicate if Master information should appear on Printer-Friendly page

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''


I then modified the list.asp as follows. There is a subroutine located near the end called DisplayMasterTableInfo. I modified this routine to first store it's output into a string variable. It then sends the string variable to the display via Response.write and then stores the string into the session variable session("strMasterHeader"). Later we will use this session variable to place the master data on the print.asp page.
Here is the new version of DisplayMasterTableInfo.

##MASTERTABLEINFO##

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

' The subroutine has been modified to store it's results into the session

' variable session("strMasterHeader"), so that the printer-friendly page

' could easily display it.

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Sub DisplayMasterTableInfo(rs)

   Dim strMasterHeader

   strMasterHeader = "<tr valign=top>"

     ##MASTERLISTFIELDS##

     strMasterHeader = strMasterHeader + "<TD class=" + Chr(34) + "blackshade" + Chr(34) + ">##LABEL##</TD>"

     ##/MASTERLISTFIELDS##

   strMasterHeader = strMasterHeader + "</tr>"
   strMasterHeader = strMasterHeader + "<tr class=" + Chr(34) + "shade" + Chr(34) + ">"

     If isObject(rs) Then

     ##MASTERLISTFIELDS##

     strMasterHeader = strMasterHeader + "<TD##WIDTH####ALIGN##>"

       ##DATABASEIMAGE##

       strImageWhere = " " & AddWrappers("##MASTERKEY##", "on") & "="  & GetData(rs.Fields(RemoveWrappers("##MASTERKEY##")), "")

       strMasterHeader = strMasterHeader + "<img ##IMAGEWIDTH## ##IMAGEHEIGHT## ##IMAGEBORDER## src=" + Chr(34) + "imager.asp?pictable=" + HTMLEncode("##MASTERTABLENAME##") + "&picfield=" + HTMLEncode("##FIELD##") + "&WHERE=" + HTMLEncode(strImageWhere) + " + Chr(34) + ">"

       ##/DATABASEIMAGE##

       ##FILEIMAGE##

       strMasterHeader = strMasterHeader + "<img ##IMAGEWIDTH## ##IMAGEHEIGHT## ##IMAGEBORDER## src=" + Chr(34) + GetData(rs.Fields("##FIELD##"), "") + Chr(34) + ">"

       ##/FILEIMAGE##

       ##TEXTFIELD##

       ##BSTART## ##ISTART##

       If IsBinaryField(rs.Fields("##FIELD##")) Then

           strMasterHeader = strMasterHeader + CreateMasterImageControl(rs, "##FIELD##", "##MASTERTABLENAME##", "##MASTERKEY##")

       Else

           strData = GetData(rs.Fields("##FIELD##"), "##FORMAT##")

           ##DBLOOKUPFIELD##

           If Not IsNull(strData) Then

               strData = Replace(strData, "'", "''")

               If IfNeedQuotes(GetFieldType("##FIELD##")) Then

                   strData = GetQuote("##FIELD##") & strData & GetQuote("##FIELD##")

               End If

               sqlt = "SELECT ##DISPLAYFIELD## FROM ##LOOKUPTABLE## WHERE ##LINKFIELD## = " & strData

               Set rst = dbConnection.Execute(sqlt)

               If Not rst.EOF Then

                   Response.Write rst(0)

               End If

               rst.Close

               Set rst= Nothing

           End If

           ##/DBLOOKUPFIELD##

           ##NOTDBLOOKUPFIELD##

           strMasterHeader = strMasterHeader + ProcessLargeText(strData)

           ##/NOTDBLOOKUPFIELD##

       End If

       ##IEND## ##BEND##

       ##/TEXTFIELD##

     strMasterHeader = strMasterHeader + "</td>"

     ##/MASTERLISTFIELDS##              

   strMasterHeader = strMasterHeader + "</tr>"

   End If
   response.write(strMasterHeader)

   session("strMasterHeader") = strMasterHeader
End Sub

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''


Now in the print.asp page look down at around line 17 or 18 for the following code

Session.LCID = ##LCID##

On Error Resume Next[/font]

Immediately after this line insert the following code which will display the header.

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

'This is a patch to put the master table info on the this "print" page

strMasterKey = Request.Form("masterkey")

If strMasterKey="" Then

   strMasterKey = Session(strTableName & "MasterKey")

End If

Session(strTableName & "MasterKey") = strMasterKey
If gstrMasterOnPrint = "Y" Then %>

 <table align="center" width="95%" CELLPADDING=3 CELLSPACING=1 BORDER=0>

   <%

   Dim strMasterHeader

   strMasterHeader = session("strMasterHeader")

   response.write(strMasterHeader)

   %>

 </table>

 <BR>

 <%

End If

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''


That's all there is to it. Good luck!

Dan <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=2899&image=1&table=forumreplies' class='bbc_emoticon' alt=':D' />