print page script - login problems  
Author Message
ll





PostPosted: 2007-11-1 4:05:22 Top

asp, print page script - login problems Hi,
I have inherited a site written in 'classic' ASP, and I am working
with a print page script. I've gotten the script to work ok,
although, as the page which has the "print this page" link is
'protected,' the page that pops up (when the "print this page" linked
is clicked) is the authentication page, rather than the page which is
supposed to be printed. The URL that appears in the in the "print
this page" link is the correct one (the page exists within a protected
folder, although even when logged on successfully, the correct page
will not appear). Thanks for any help you can provide.

Here is the code I used. The top of the two codes listed is the
'calling' page in which the "print this page" link is located.


<%Session.Timeout=200%>
<%if Session("AMSADMINusername") <> "" then
Session("AMSCOMMusername")= Session("AMSADMINusername")
end if%>

<%if isempty(Session("AMSCOMMusername")) then
Response.Redirect "/ams/index.asp"
end if%>
<%role="comms"%>
<html>
<head></head>
<body>
<!--code below in body of calling page -->
<script Language="JavaScript">
<!-- hide from old browsers
// ppb and ppe are the start and end of the dynamic link
// window.location.href will refer to the current URL of the page
// it's nice to make it open in a new window too! i.e.
target=_blank

var ppb = "<a href=/print/printpage.asp?ref=";
var ppe = " target=_blank>Print This Page</a><br>";
document.write(ppb + window.location.href + ppe);

//end -->
</script>

<%breadcrumb="main menu"%>
<!--#include virtual="/ams/common/layout/headerComm.asp"-->
<!--<h3 align="left">Task Assigned:</h3>
<p align="left">Dear Curriculum Committee Members, <br>
Please review the reports under View Courses Under Review link below
by July 21. <em>Posted July 7, 2005.</em></p>
<br>-->
<!--#include virtual="/ams/common/incSearchByKeywordGUI.asp"-->

<!--#include virtual="/common/Layout/footer_training_ams_b.asp"-->
<!--#include virtual="/common/Layout/footerams.htm"-->


-----------------------------------------------------------------------------------------------------------------


<!-- code below in print page -->
<%
option explicit
Response.Buffer = True

'declare a variable for the reference page,
'the XMLHTTP Object, and the regular expressions used

Dim RefPage, objXMLHTTP, RegEx

'set the RefPage variable to the "ref" querystring
'the JavaScript function above passes the current page URL
'You can use the Request.ServerVariables("HTTP_REFERER") to
'get the page as a last option if needed

RefPage = Request.QueryString("ref")
if RefPage = "" then
response.write "<h3>Invalid reference page</h3>"
response.end
end if

'set the objXMLHTTP object to the XMLHTTP object from Microsoft
Set objXMLHTTP = Server.CreateObject("Microsoft.XMLHTTP")


'perform the HTTP "GET" method via the XMLHTTP object to retrieve
'the called page
objXMLHTTP.Open "GET", RefPage, False
objXMLHTTP.Send

'give RefPage the text(HTML) from the call above
RefPage = objXMLHTTP.responseText

'Create built In Regular Expression object that
'is now included with VBScript version5
Set RegEx = New RegExp
RegEx.Global = True


'Set the pattern To look For <!-- START PPOMIT --> tags
RegEx.Pattern = "<!-- START PPOMIT -->"

'replace the comment pattern with a rare ASCII character
'i've choosed No 253 in this case, I suppose if you're speaking
'a language other than English this may not be the case but
'the reasoning here is so it will be unique and not interfere
'this the main page content
RefPage = RegEx.Replace(refpage,( chr(253) ))

'Set the pattern To look For <!-- END PPOMIT --> tags
RegEx.Pattern = "<!-- END PPOMIT -->"

'This time make it replace the comment with another rare
'ASCII character, NOT the one used above
RefPage = RegEx.Replace(refpage,( chr(254) ))

'Use this regular expression to "cut out" HTML between the
'start and end comments now the new ASCII characters
RegEx.Pattern = chr(253) & "[^" & chr(254) & "]*" & chr(254)

'This will perform the actual striping
RefPage = RegEx.Replace(refpage, " " )

'Don't forget to tidy up :-)
Set RegEx = Nothing
Set objXMLHTTP = Nothing

'Output your Printer Friendly Page!
Response.Write RefPage
%>

 
jp2code





PostPosted: 2007-11-1 4:25:00 Top

asp >> print page script - login problems Instead of all that, why don't you throw a little JavaScript onto your
webpage:

<input type="button" value="Print" onClick="parent.print()">

One simple line. Will that work?

"ll" <email***@***.com> wrote in message
news:email***@***.com...
> Hi,
> I have inherited a site written in 'classic' ASP, and I am working
> with a print page script. I've gotten the script to work ok,
> although, as the page which has the "print this page" link is
> 'protected,' the page that pops up (when the "print this page" linked
> is clicked) is the authentication page, rather than the page which is
> supposed to be printed. The URL that appears in the in the "print
> this page" link is the correct one (the page exists within a protected
> folder, although even when logged on successfully, the correct page
> will not appear). Thanks for any help you can provide.
>


 
ll





PostPosted: 2007-11-1 4:41:00 Top

asp >> print page script - login problems On Oct 31, 3:25 pm, "jp2code" <poojo.com/mail> wrote:
> Instead of all that, why don't you throw a little JavaScript onto your
> webpage:
>
> <input type="button" value="Print" onClick="parent.print()">
>
> One simple line. Will that work?
>
> "ll" <email***@***.com> wrote in message
>
> news:email***@***.com...
>
> > Hi,
> > I have inherited a site written in 'classic' ASP, and I am working
> > with a print page script. I've gotten the script to work ok,
> > although, as the page which has the "print this page" link is
> > 'protected,' the page that pops up (when the "print this page" linked
> > is clicked) is the authentication page, rather than the page which is
> > supposed to be printed. The URL that appears in the in the "print
> > this page" link is the correct one (the page exists within a protected
> > folder, although even when logged on successfully, the correct page
> > will not appear). Thanks for any help you can provide.



Well, there are some elements that need to be resized for print. I
might try that route and see what happens.