Announcement

Collapse
No announcement yet.

#includes for asp code - how?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    #includes for asp code - how?

    I am a newbie at this asp idea...

    I have several asp pages with VB script sprinkled in the pages. And I wish to have a heading appear on every web page. Same heading. That heading is a mix of HTML and ASP VB Script.

    I cannot figure out how to #include or whatever so that a file with the common code is referenced by each using page. I looked around; got mired down in Server Side Includes which apparently the HomeSeer web server doesn't support. Then I stumbled with the HTML comment tag for include a file. Stumped on that one.

    Thanks in advance for anyone who can show me how to #include an ASP file, invoked by an ASP file.

    steve

    #2
    <!--#include "filename.asp"-->

    Note that you can't include files that aren't in the HTML directory somewhere this way. For a "common header" this is probably no problem, but when you start wanting to include the functions you've written and put in your scripts/include directory, you're out of luck until/unless Rich "fixes" this.

    Nucleus Home Automation
    News, support, and updates for Rover, Network Monitor, TimeIcons, and more

    Comment


      #3
      thanks. I was trying to code for an asp file which was in a subdirectory of the homeseer html directory. I believe you are saying that this cannot now be done - the file must be in the html directory. I'll try that.

      Comment


        #4
        Paul Augusto pointed this out to me and I now use it for all my new includes. As an example to include the script includes in my AudreyUtilitiesTest.asp I use...
        <%
        <!--#include virtual= "/../Scripts/Includes/AudreyUtilityExtensions.inc"-->
        <!--#include virtual= "/../Scripts/Includes/AudreyUtilities.inc"-->
        <!--#include virtual= "/../Scripts/Includes/IniTool.inc"-->
        %>

        Comment


          #5
          The other thing that might not be that obvious from Michael's post is that the includes don't need the <% %> tags in them if they are between the tags in the asp. This allows you to share the same include between scripts and asp pages.

          I'm not sure if this is unique to the HS web server - that's the only one I run.


          Paul

          Comment


            #6
            With HomeSeer's web server (latest beta), one gives a file name is in the HomeSeer options setting for the customize web page. Can this file be an asp file or must it (the root file) be HTML?

            I have a file which is all-HTML, no script, but if I give it an ASP extension, HomeSeer says error in line 1 statement expected. The file has no <% tag in it. That same file works fine if it has an HTM suffix. I presumed that the server would take the contents of an ASP which has no <% tags and just process it as is. (I named it as ASP as a starting point in testing - it would later contain script code).

            Sorry for the dumb newbie question.

            Comment


              #7
              asp pages need, as the first line in the file
              <%@ Language=VBScript %> or
              <%@Language=javascript%> I believe. At east if your running your pages on IIS I'm pretty sure Rich is requiring it as well.

              -Rupp
              -Rupp
              sigpic

              Comment


                #8
                Mike, that's great... I've read several threads here trying to find the trick of making that work and agreeing that it wasn't possible. Cool.

                Nucleus Home Automation
                News, support, and updates for Rover, Network Monitor, TimeIcons, and more

                Comment


                  #9
                  <!--#include virtual= "/somefile.asp"-->
                  and
                  <!--#include file= "/somefile.asp"-->

                  I have used both and I'm not sure of the difference................................JG
                  HS2PRO - Ocelot, SecuIR, Secu16, Attendence Management Alarm Interface, X-10, LCD Studio VFD Display, 3 Apexis IP Cams, Custom Software Interfaces, GMQ Geiger Graphing
                  HS3PRO - Testing

                  Comment


                    #10
                    Thanks a ba-zillion to Rupp and Paul - I now havea an ASP working as the root page and a lot of VBScript working too.

                    This is on my project to have web pages sent to my TV set's aux-video in from the HomeSeer PC. Web pages contain specially formatted HomeSeer things, TV listings for each evening (reparse of GIST.COM), weather, etc. Scroll the pages and switch pages using the TV's remote and irMAN hardware.

                    Comment


                      #11
                      Jebus,
                      In the IIS world, Virtual is relative to root of the server's virtual directory (e.g. /HTML or /wwwroot), while File is relative to the file that makes the include. I did not play around to see what homeseer's convention is. I have always used Virtual with it.

                      Comment


                        #12
                        Thanks Michael
                        That clears up some things I was thinkin bout.
                        I believe now that INCLUDE FILE pertains to CFGUYS filecontents.asp, which is where I had started to use the "include file" statement. I now use that asp and statement exclusively for all asp's....JG
                        HS2PRO - Ocelot, SecuIR, Secu16, Attendence Management Alarm Interface, X-10, LCD Studio VFD Display, 3 Apexis IP Cams, Custom Software Interfaces, GMQ Geiger Graphing
                        HS3PRO - Testing

                        Comment


                          #13
                          If I have functions on the and ASP page and I want to separate them out, can I just cut/paste into a new page, place into includes dir, and make an include reference <!--#include virtual= "/includes/CtrlFunctions.asp"--> at the top of the pages?

                          Comment


                            #14
                            Yes you can, that is the typical use of include files so common functions can be used in multiple applications

                            Comment

                            Working...
                            X