print page script - login problems

Discussion in 'ASP General' started by ll, Oct 31, 2007.

  1. ll

    ll Guest

    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
    %>
    ll, Oct 31, 2007
    #1
    1. Advertising

  2. ll

    jp2code Guest

    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" <> wrote in message
    news:...
    > 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.
    >
    jp2code, Oct 31, 2007
    #2
    1. Advertising

  3. ll

    ll Guest

    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" <> wrote in message
    >
    > news:...
    >
    > > 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.
    ll, Oct 31, 2007
    #3
  4. Gazing into my crystal ball I observed ll <>
    writing in news::

    > 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" <> wrote in message
    >>
    >> news:...
    >>
    >> > 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.
    >
    >


    <style type="text/css">
    @media screen {
    #content {
    width:80%;
    font-size:100%;
    }
    }
    @media print {
    #content {
    width:100%;
    font-size:12pt;
    }
    #footer {display:none}
    }
    </style>
    </head>
    <body>
    <div id="content">
    This will be at 100% of the user's chosen font size for screen. It will
    print at 12points. This does not require anything except the user
    hitting the print button on their browser.
    </div>
    <div id="footer">This will not print at all.</div>
    </body>

    --
    Adrienne Boswell at Home
    Arbpen Web Site Design Services
    http://www.cavalcade-of-coding.info
    Please respond to the group so others can share
    Adrienne Boswell, Nov 1, 2007
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Hermit Dave

    Forms Login Page Not Login Out

    Hermit Dave, Jan 12, 2004, in forum: ASP .Net
    Replies:
    5
    Views:
    453
    Hermit Dave
    Jan 13, 2004
  2. DavidADEW
    Replies:
    2
    Views:
    2,693
    DavidADEW
    Sep 1, 2006
  3. keto
    Replies:
    0
    Views:
    897
  4. Shannon

    login page stays on login page

    Shannon, Jan 9, 2008, in forum: ASP .Net
    Replies:
    2
    Views:
    518
    Shannon
    Jan 9, 2008
  5. David Cournapeau

    print a vs print '%s' % a vs print '%f' a

    David Cournapeau, Dec 30, 2008, in forum: Python
    Replies:
    0
    Views:
    335
    David Cournapeau
    Dec 30, 2008
Loading...

Share This Page