Server-Side Includes and ASP

Discussion in 'ASP General' started by Nathan Sokalski, May 5, 2005.

  1. I have a segment of HTML code that I want to put in a server-side include.
    All but one line of this code will be constant in all file it is included
    in. However, there are many places in the HTML that include double quotes.
    From what I can conclude, this leaves me with the following options:

    1. Make several files to include, 1 for the constant HTML before the
    non-constant HTML, 1 for the line of code that is not constant, and 1 for
    the constant HTML after the non-constant HTML.

    2. Convert the constant html into strings that are created using Chr()
    function for all the double quotes and written using Response.Write().

    Option 1 requires less effort, but would require more files to keep track of
    and would require me to pull 3 files in rather than just 1. Option 2 allows
    me to do everything with one file, but would be harder to edit because the
    code will no longer look like HTML. Any suggestions? Thanks.
     
    Nathan Sokalski, May 5, 2005
    #1
    1. Advertisements

  2. Hello,

    Option 3 : Why not put a variable in your main template, then affecting
    it before including the file.
    Here is an example :

    template.asp :
    <HTML><BODY>
    Page Header
    <%=MyVar%>
    Page Footer
    </BODY></HTML>
    ------------------

    And your main page could be :
    <%
    Dim MyVar
    MyVar = "Some text"
    %>
    <!-- #include file="template.asp" -->
     
    Jean-Pierre Thomasset, May 5, 2005
    #2
    1. Advertisements

  3. I don't think that solves my problem, because I still have to make
    everything into a string (in your example MyVar), which presents the same
    problem I mentioned in solution #2.
     
    Nathan Sokalski, May 6, 2005
    #3
  4. Then why not encapsulate everything in a procedure :

    template.asp :
    <HTML><BODY>
    Page Header
    <%=MySub%>
    Page Footer
    </BODY></HTML>
    -----------------

    And your main page could be :
    <%
    Sub MySub
    ' some vbscript
    %>
    Some text with html tags
    <%
    End Sub
    %>
    <!-- #include file="template.asp" -->
     
    Jean-Pierre Thomasset, May 6, 2005
    #4
    1. Advertisements

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.