locked
Get a relative path so any page in any folder can include the proper file RRS feed

  • Question

  • User244223299 posted

    I simply have to use this code (which works fine) : Server.Execute("includes/_temp.inc")

    But want to apply it so it becomes "relative" - so all my pages can refer to this single chunk of code....

    (Get a relative path so any page in any folder can include the proper file)

     

    The challenge is i must use this "relative" path while i am in a "IF/Then/Else" statement

    A simple include code won't work (seems like server preceeds it as plain HTML) this is why i turned to "Server. Execute"

     

    Any help or contact would be appreciated!

    Friday, July 4, 2014 1:39 PM

Answers

  • User753101303 posted

    Unclear.

    In ASP classic if you use #include inside a server side script block it is included as part of this script block. If included inside HTML markup it is part of the markup.

    Waht is the problem you have ? I'm not sure what you mean with "seems like server preceeds it as plain HTML". IMO rather than just trying something else because #include doesn't seems to work it's best to understand the exact problem so that you can fix it as needed. If you have some content in addition to the #include it has to come from somewhere.

    Hopefully this an app you have to support. If you just begin with this, using ASP.NET rather than ASP classic will be better.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, July 5, 2014 8:32 AM

All replies

  • User753101303 posted

    Hi,

    "ASP Classic" question ? Actually it seems you want an *absolute* path such as /includes/_temp.inc so that it always find the folder Under the root of the web site.. The #include directive does work fine. It depends if you are doing this outside or Inside a server side code block. 

    With ASP.NET, you would move away from this model (based on compiled code rather than on source files so your code is callable as soon as this is in scope)

    Friday, July 4, 2014 1:58 PM
  • User244223299 posted

    Thanks for the answer! It gives me some idea. But I'm doing this outside the server side. How should I be doing it? 

    Friday, July 4, 2014 4:39 PM
  • User753101303 posted

    Unclear.

    In ASP classic if you use #include inside a server side script block it is included as part of this script block. If included inside HTML markup it is part of the markup.

    Waht is the problem you have ? I'm not sure what you mean with "seems like server preceeds it as plain HTML". IMO rather than just trying something else because #include doesn't seems to work it's best to understand the exact problem so that you can fix it as needed. If you have some content in addition to the #include it has to come from somewhere.

    Hopefully this an app you have to support. If you just begin with this, using ASP.NET rather than ASP classic will be better.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Saturday, July 5, 2014 8:32 AM
  • User244223299 posted

    Thank you for your help. Did a script directly on top of the page. It works perfect! Thanks!!!

    Monday, July 7, 2014 11:06 AM