REAL dynamic includes... At Last!

Results 1 to 3 of 3

Thread: REAL dynamic includes... At Last!

  1. #1
    Join Date
    Dec 1969
    Posts
    20

    Default REAL dynamic includes... At Last!

    I&#039;ve read the 4guys site for years and the articles have helped me out on many occasions, so I thought I&#039;d try and give something back...<BR><BR>Real dynamic includes:<BR>I developed this technique while working on a legacy system and have never seen it done before, it has opened up a load of different applications. Here is the concept...<BR><BR>The page being executed is itself an object, hence it can reference itself using the "me" keyword. We store the current page reference in a session variable using "me". We then call a child page based on some criteria using server.execute. On the child page we use the session variable to reference ANYTHING that is on the parent page. As Gordon Ramsay would say... "dynamic includes, done."<BR><BR>Sample code:<BR><BR>Page1.asp -<BR>&#060;%<BR> dim strTest : strTest = "hello"<BR> response.write "Variable ""strTest"" on Page1= " & strTest & "&#060;br /&#062;"<BR> set session("passThrough") = me<BR> server.execute("Page2.asp")<BR> response.write "We are back in Page1 and ""strTest"" is now= " & strTest & "&#060;br /&#062;"<BR> set session("passThrough") = nothing<BR>%&#062; <BR><BR>Page2.asp -<BR>&#060;%<BR> session("passThrough").strTest = "goodbye"<BR> response.write "We are in Page2 and have just modified Page1&#039;s ""strTest"" variable &#060;br /&#062;"<BR>%&#062;<BR><BR>I hope you can see the possibilities.<BR><BR>Cheers,<BR><BR>Reiss ;op

  2. #2
    Join Date
    Mar 2013
    Posts
    1

    Default

    Did you ever really get this to run? I get an error on Page2 saying 'Object doesn't support this property or method: strTest''.

  3. #3
    Join Date
    Dec 1969
    Posts
    96,031

    Default

    That always was a pretty bogus idea.

    Doing
    Code:
    Set Session("passThrough") = me
    is supposed to set the session variable to a reference to the current page. But that is *NOT* a thread-safe thing to do, even if it happened to work! Could have disastrous consequence on your site performance.

    I would definitely ignore that post.

    What you *can* do is simply pass DATA back and forth in session variable(s) and then remove the session variable(s) when you are done. You could even pass an array back and forth, so you are only using one session variable.

    Something like:
    Code:
    ' *** page 1 ***
    Session("passThrough") = Array("testing", 3.14159286, "john doe" )
    
    ' *** page 2 ***
    info = Session("passThrough")
    message = info(0)
    number = info(1)
    messageFrom = info(2)
    ... code code code ...
    info(0) = "message processed"
    
    ' *** page 1 again 
    info = Session("passThrough")
    statusMessage = info(0)
    ...
    Session.Contents.Remove("passThrough") ' no longer needed

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •