response.writing an include tag...not working?

Discussion in 'ASP .Net' started by darrel, Nov 3, 2004.

  1. darrel

    darrel Guest

    I'm trying to load an include dynamically. So, I'm writing out the include
    tag via a response.write:

    response.write("<!--#include virtual='" & contentIncludeFile &"' -->")

    however, that's writing out the include tag AFTER the page is processed,
    obviously. Any suggestions for a way around this? Should I instead load the
    contents of the include file as a string and then write that out?

    -Darrel
    darrel, Nov 3, 2004
    #1
    1. Advertising

  2. Can u try <%= %> and see but not sure!


    "darrel" wrote:

    > I'm trying to load an include dynamically. So, I'm writing out the include
    > tag via a response.write:
    >
    > response.write("<!--#include virtual='" & contentIncludeFile &"' -->")
    >
    > however, that's writing out the include tag AFTER the page is processed,
    > obviously. Any suggestions for a way around this? Should I instead load the
    > contents of the include file as a string and then write that out?
    >
    > -Darrel
    >
    >
    >
    =?Utf-8?B?UGF0cmljay5PLklnZQ==?=, Nov 4, 2004
    #2
    1. Advertising

  3. darrel

    Scott M. Guest

    Include directives are processed BEFORE any other server-side code and
    because of this, you can't do what you are trying because the variable
    "contentIncludeFile" hasn't been resolved yet.

    This is not a .NET issue/question. It is how the server-side INCLUDE
    directive is handled by the server.

    Why not ditch "Response.Write" statements as well as INCLUDE directives and
    start using .NET techniques such as labels (instead of response.write) and
    User Controls (instead of SSI's)?




    "darrel" <> wrote in message
    news:...
    > I'm trying to load an include dynamically. So, I'm writing out the include
    > tag via a response.write:
    >
    > response.write("<!--#include virtual='" & contentIncludeFile &"' -->")
    >
    > however, that's writing out the include tag AFTER the page is processed,
    > obviously. Any suggestions for a way around this? Should I instead load
    > the
    > contents of the include file as a string and then write that out?
    >
    > -Darrel
    >
    >
    Scott M., Nov 4, 2004
    #3
  4. darrel

    Darrel Guest

    > Why not ditch "Response.Write" statements as well as INCLUDE directives
    > and start using .NET techniques such as labels (instead of response.write)
    > and User Controls (instead of SSI's)?


    Because sometimes all you need is a response.write and an SSI. ;o)

    I like .net, but really, I shouldn' have to use a UC just to include some
    text.I find .net a huge improvement, but there's a lot of overkill at the
    basic level.

    In the end, I've got it working by opening the file, reading it into a
    string, and sending the string back to the page. It works fine, but seems a
    lot more complicated than a simple old include file ;o)

    -Darrel
    Darrel, Nov 4, 2004
    #4
  5. <<I shouldn' have to use a UC just to include some text.>>

    Agreed, and you don't have to. Check out the Literal control. You just need
    to set its Text property. The only thing that will show up on the rendered
    page is the string you set for it (and in the location on the page in which
    you have located the Literal control at design time).

    -GH


    "Darrel" <> wrote in message
    news:...
    > > Why not ditch "Response.Write" statements as well as INCLUDE directives
    > > and start using .NET techniques such as labels (instead of

    response.write)
    > > and User Controls (instead of SSI's)?

    >
    > Because sometimes all you need is a response.write and an SSI. ;o)
    >
    > I like .net, but really, I shouldn' have to use a UC just to include some
    > text.I find .net a huge improvement, but there's a lot of overkill at the
    > basic level.
    >
    > In the end, I've got it working by opening the file, reading it into a
    > string, and sending the string back to the page. It works fine, but seems

    a
    > lot more complicated than a simple old include file ;o)
    >
    > -Darrel
    >
    >
    Guadala Harry, Nov 4, 2004
    #5
    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. gaurav tyagi
    Replies:
    14
    Views:
    1,301
    gaurav tyagi
    Jan 20, 2006
  2. shruds
    Replies:
    1
    Views:
    709
    John C. Bollinger
    Jan 27, 2006
  3. HockeyFan
    Replies:
    2
    Views:
    397
    HockeyFan
    Dec 7, 2006
  4. Andreas Bogenberger
    Replies:
    3
    Views:
    858
    Andreas Bogenberger
    Feb 22, 2008
  5. Eqbal Z
    Replies:
    6
    Views:
    170
    Eqbal Z
    Aug 27, 2003
Loading...

Share This Page