writeline containing '<%'

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Linto81
    New Member
    • Jun 2008
    • 7

    writeline containing '<%'

    Hi all

    I am using a writeline method to create a new page containing all required code.

    However, included within the page code are various asp calls.

    The problem I have is that the asp page writing the page will error every time it comes accross "<%" or "%>" within the writeline.

    Do any of you have any ideas on how to get around this? Many thanks in advance...

    eg. Anything under line84 is going to err...
    Code:
     
    80 writethis.WriteLine("<!--#include virtual=""/alt/alt.asp"" -->")
    81 writethis.WriteLine("<meta http-equiv=""Content-Type"" content=""text/html; charset=iso-8859-1"">")
    82 writethis.WriteLine("<link rel=""stylesheet"" href=""/ccss/ccl.css"" type=""text/css"">")
    83 writethis.WriteLine("<script language=""javascript"">")
    84 writethis.WriteLine("window.myMen = ""<%=session(""myMen"")%>"";")
    85 writethis.WriteLine("window.mySub = ""<%=session(""mySub"")%>"";")
    86 writethis.WriteLine("</script>")
    Last edited by DrBunchman; Jun 17 '08, 02:11 PM. Reason: Added code tags - Please use the # button
  • DrBunchman
    Recognized Expert Contributor
    • Jan 2008
    • 979

    #2
    Hi Linto81,

    Have you tried using the following replacements:

    < can be replaced with &lt;
    > can be replaced with &gt;

    See if those work for you.

    Dr B

    Comment

    • Linto81
      New Member
      • Jun 2008
      • 7

      #3
      Hi and thanks...

      It does stop the error, but then when the page displays, any asp code is actually written to the page as HTML rather than as working code.

      so within your page, you will see items such as <% whatever code here %> instead of it just working!

      Thanks, but not quite there unfort...

      Comment

      • DrBunchman
        Recognized Expert Contributor
        • Jan 2008
        • 979

        #4
        What about separating the ASP brackets like this:
        Code:
         
        84 writethis.WriteLine("window.myMen = ""<" + "%=session(""myMen"")%" + ">"";")
        Any good?

        Dr B

        Comment

        • jeffstl
          Recognized Expert Contributor
          • Feb 2008
          • 432

          #5
          I can't help but also wonder the order of processing here.

          Since a .asp page is compiled and executed on the server when it is requested, I am confused as to how you are using this method.

          So a .js program generates the page when a user requests it? That would generate a .asp page but in order for it to work it has to be requested in a similiar fashion from the web server.

          In other words the bottom line is that whatever .asp page your code is generating ......has to at some point be requested from the browser...... But how do you generate the page and execute the page with a single user request ?

          I am mostly asking out of curiousity.

          Comment

          • Linto81
            New Member
            • Jun 2008
            • 7

            #6
            Dr B... please accept a virtual pint of your favourite ale! Thanks...

            It is always the simplest thing that eludes you isn't it?! ALl I did was replace the + for a & as I am doing this is ASp not JS. Which might asnwer your question Jeff...

            It is oart of a content management system. When you add an item to the menu, you can request it to create a page at the same time. It does this by using the asp writeline method having written the file to a folder.

            But, obviously, the site pages have various asp calls and includes in them so you have to be careful how you write the page or else it will fail on display.

            I hope that answers your question. (I know I can easily just call a page and then the content into the same page using an id number, but the site it drives is much more slick and requires no calls for id numbers - it does that using session variables (even telling a collapsing menu what to open on the next page).. its v complicated... hence the reason I didn't think about the simple stuff!!

            Thanks guys...

            Comment

            • DrBunchman
              Recognized Expert Contributor
              • Jan 2008
              • 979

              #7
              Originally posted by Linto81
              Dr B... please accept a virtual pint of your favourite ale! Thanks...
              Gratefully drunk!

              Glad that you got it sorted.

              Dr B

              Comment

              Working...