SSI, Server-side includes (but in a script)

Discussion in 'Classic ASP' started by cmadore, Sep 14, 2004.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. I would like to accomplish the same function as a SSI (server-side include), but in a script.

    Let me provide you some background as to what I would like to do:

    Based upon a random number, I would like to include a page associated with that particular number. Here?s my code:

    <% Function ParseSolutions
    'Generate Random Number
    Dim PageRnd
    Randomize
    PageRnd = Int((8-0+1) * Rnd + 0)

    'Load up array with locations of Solution Promo pages
    Dim RndSolutionsPage(8)
    RndSolutionsPage(0)="frontPagePromos/solutions/enterprise-promo.htm"
    RndSolutionsPage(1)="frontPagePromos/solutions/government-promo.htm"
    RndSolutionsPage(2)="frontPagePromos/solutions/healthcare-promo.htm"
    RndSolutionsPage(3)="frontPagePromos/solutions/higher-ed-promo.htm"
    RndSolutionsPage(4)="frontPagePromos/solutions/hospitality-promo.htm"
    RndSolutionsPage(5)="frontPagePromos/solutions/k-12-promo.htm"
    RndSolutionsPage(6)="frontPagePromos/solutions/prof-serv-promo.htm"
    RndSolutionsPage(7)="frontPagePromos/solutions/retail-promo.htm"
    RndSolutionsPage(8)="frontPagePromos/solutions/sm-business-promo.htm"


    End Function
    %>

    <!-- include file=<%=RndSolutionsPage(PageRnd)%> à

    How do I dynamically (within a script) call the associated page?

    This didn?t work (for obvious reasons): <!-- include file=<%=RndSolutionsPage(PageRnd)%> à


    Thanks for your help. I?m just getting back to programming and honestly feel like a beginner.


    C Madore
     
  2. Bruce

    Bruce DiscountASP.NET Staff

    I assume this is a asp page

    Save the random code as an inc or asp file and add a response.write


    <!--#include virtual="/include/random.asp"-->


    quote:Originally posted by cmadore

    I would like to accomplish the same function as a SSI (server-side include), but in a script.

    Let me provide you some background as to what I would like to do:

    Based upon a random number, I would like to include a page associated with that particular number. Here?s my code:

    <% Function ParseSolutions
    'Generate Random Number
    Dim PageRnd
    Randomize
    PageRnd = Int((8-0+1) * Rnd + 0)

    'Load up array with locations of Solution Promo pages
    Dim RndSolutionsPage(8)
    RndSolutionsPage(0)="frontPagePromos/solutions/enterprise-promo.htm"
    RndSolutionsPage(1)="frontPagePromos/solutions/government-promo.htm"
    RndSolutionsPage(2)="frontPagePromos/solutions/healthcare-promo.htm"
    RndSolutionsPage(3)="frontPagePromos/solutions/higher-ed-promo.htm"
    RndSolutionsPage(4)="frontPagePromos/solutions/hospitality-promo.htm"
    RndSolutionsPage(5)="frontPagePromos/solutions/k-12-promo.htm"
    RndSolutionsPage(6)="frontPagePromos/solutions/prof-serv-promo.htm"
    RndSolutionsPage(7)="frontPagePromos/solutions/retail-promo.htm"
    RndSolutionsPage(8)="frontPagePromos/solutions/sm-business-promo.htm"


    End Function
    %>

    <!-- include file=<%=RndSolutionsPage(PageRnd)%> à

    How do I dynamically (within a script) call the associated page?

    This didn?t work (for obvious reasons): <!-- include file=<%=RndSolutionsPage(PageRnd)%> à


    Thanks for your help. I?m just getting back to programming and honestly feel like a beginner.


    C Madore
    </blockquote id="quote"></font id="quote">

    B.

    DiscountASP.NET
    http://www.DiscountASP.NET
     
  3. Thanks for the reply Bruce. Yes, this is an ASP page. I appreciate your reply; however, you didn't answer my question. Is there a function that will perform the equivilant of a server-side include from WITHIN a script?

    Inquiring mind would like to know.

    Thanks.

    C.

    quote:Originally posted by bruce

    I assume this is a asp page

    Save the random code as an inc or asp file and add a response.write


    <!--#include virtual="/include/random.asp"-->


    quote:Originally posted by cmadore

    I would like to accomplish the same function as a SSI (server-side include), but in a script.

    Let me provide you some background as to what I would like to do:

    Based upon a random number, I would like to include a page associated with that particular number. Here?s my code:

    <% Function ParseSolutions
    'Generate Random Number
    Dim PageRnd
    Randomize
    PageRnd = Int((8-0+1) * Rnd + 0)

    'Load up array with locations of Solution Promo pages
    Dim RndSolutionsPage(8)
    RndSolutionsPage(0)="frontPagePromos/solutions/enterprise-promo.htm"
    RndSolutionsPage(1)="frontPagePromos/solutions/government-promo.htm"
    RndSolutionsPage(2)="frontPagePromos/solutions/healthcare-promo.htm"
    RndSolutionsPage(3)="frontPagePromos/solutions/higher-ed-promo.htm"
    RndSolutionsPage(4)="frontPagePromos/solutions/hospitality-promo.htm"
    RndSolutionsPage(5)="frontPagePromos/solutions/k-12-promo.htm"
    RndSolutionsPage(6)="frontPagePromos/solutions/prof-serv-promo.htm"
    RndSolutionsPage(7)="frontPagePromos/solutions/retail-promo.htm"
    RndSolutionsPage(8)="frontPagePromos/solutions/sm-business-promo.htm"


    End Function
    %>

    <!-- include file=<%=RndSolutionsPage(PageRnd)%> à

    How do I dynamically (within a script) call the associated page?

    This didn?t work (for obvious reasons): <!-- include file=<%=RndSolutionsPage(PageRnd)%> à


    Thanks for your help. I?m just getting back to programming and honestly feel like a beginner.


    C Madore
    </blockquote id="quote"></font id="quote">

    B.

    DiscountASP.NET
    http://www.DiscountASP.NET

    </blockquote id="quote"></font id="quote">

    C Madore
     
  4. I guess I should be more specific: I'm looking for a function that will call html from a file and then parse - all from WITHIN a script. (I'm aware that these may be 2 functions.) Please help.

    Craig

    quote:Originally posted by cmadore

    Thanks for the reply Bruce. Yes, this is an ASP page. I appreciate your reply; however, you didn't answer my question. Is there a function that will perform the equivilant of a server-side include from WITHIN a script?

    Inquiring mind would like to know.

    Thanks.

    C.

    quote:Originally posted by bruce

    I assume this is a asp page

    Save the random code as an inc or asp file and add a response.write


    <!--#include virtual="/include/random.asp"-->


    quote:Originally posted by cmadore

    I would like to accomplish the same function as a SSI (server-side include), but in a script.

    Let me provide you some background as to what I would like to do:

    Based upon a random number, I would like to include a page associated with that particular number. Here?s my code:

    <% Function ParseSolutions
    'Generate Random Number
    Dim PageRnd
    Randomize
    PageRnd = Int((8-0+1) * Rnd + 0)

    'Load up array with locations of Solution Promo pages
    Dim RndSolutionsPage(8)
    RndSolutionsPage(0)="frontPagePromos/solutions/enterprise-promo.htm"
    RndSolutionsPage(1)="frontPagePromos/solutions/government-promo.htm"
    RndSolutionsPage(2)="frontPagePromos/solutions/healthcare-promo.htm"
    RndSolutionsPage(3)="frontPagePromos/solutions/higher-ed-promo.htm"
    RndSolutionsPage(4)="frontPagePromos/solutions/hospitality-promo.htm"
    RndSolutionsPage(5)="frontPagePromos/solutions/k-12-promo.htm"
    RndSolutionsPage(6)="frontPagePromos/solutions/prof-serv-promo.htm"
    RndSolutionsPage(7)="frontPagePromos/solutions/retail-promo.htm"
    RndSolutionsPage(8)="frontPagePromos/solutions/sm-business-promo.htm"


    End Function
    %>

    <!-- include file=<%=RndSolutionsPage(PageRnd)%> à

    How do I dynamically (within a script) call the associated page?

    This didn?t work (for obvious reasons): <!-- include file=<%=RndSolutionsPage(PageRnd)%> à


    Thanks for your help. I?m just getting back to programming and honestly feel like a beginner.


    C Madore
    </blockquote id="quote"></font id="quote">

    B.

    DiscountASP.NET
    http://www.DiscountASP.NET

    </blockquote id="quote"></font id="quote">

    C Madore
    </blockquote id="quote"></font id="quote">

    C Madore
     
  5. Here is your code it has some problems:
     
  6. Not in classic ASP.

    You can include a file.

    Also you can make a seperate ASP file as a class file, then include it in your main ASP file. Create an object in that file to the class and reference functions/subs from that.

    Also, you can open a text/html file and then write it to the page in ASP. You can create templates and then using script open them in the script and change (replace) things in them and the write them to the screen.

    Only other option is to use javascript to call the script but then it gets complicated, but thats another way to do it.

    eg:

    <script language="JavaScript" src="RndSolutionsPage.asp"></script>

    or calling querystrings in the ASP page:

    <script language="JavaScript" src="RndSolutionsPage.asp?rnd=1"></script>

    and same but say using a VBscript variable on the loading page:

    <script language="JavaScript" src="RndSolutionsPage.asp?rnd=<%=PageRnd%>"></script>

    ONE LAST WAY, is to use an img tag, depends on what you want to do as it wont do much, compared to the above. Thats how I use to use my tracking scripts I wrote (been a while).
    Eg: <img src="tracking.asp" width="1" height="1" border="0">


    Rory
     
Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page