Inluding a file in ASP+

Discussion in 'ASP .Net' started by Andrew Price, Feb 1, 2005.

  1. Andrew Price

    Andrew Price Guest

    Hi I am very new to ASP+, i have a background in Coldfusion and ASP.

    Anyway what i want to do is include a file set by a varianle so

    apologies for the phsedo like code....
    <%
    dim myFileName
    myFileName = 'pageToInclude.aspx'
    %>

    <html>
    <body>
    ...
    ....
    <%
    include myFileName
    %>

    </body>
    </html>


    anyone know, or can point me in the direction of some useful tutorials

    thankyou

    Andrew
     
    Andrew Price, Feb 1, 2005
    #1
    1. Advertising

  2. Andrew Price

    Patrice Guest

    This is <!--#include file="test.aspx"-->

    That said it is condisered as legacy. In ASP.NET, it is likely better to use
    a user control... (.ascx file)

    Patrice

    --

    "Andrew Price" <> a écrit dans le message de
    news:CjILd.462$...
    > Hi I am very new to ASP+, i have a background in Coldfusion and ASP.
    >
    > Anyway what i want to do is include a file set by a varianle so
    >
    > apologies for the phsedo like code....
    > <%
    > dim myFileName
    > myFileName = 'pageToInclude.aspx'
    > %>
    >
    > <html>
    > <body>
    > ..
    > ...
    > <%
    > include myFileName
    > %>
    >
    > </body>
    > </html>
    >
    >
    > anyone know, or can point me in the direction of some useful tutorials
    >
    > thankyou
    >
    > Andrew
    >
    >
     
    Patrice, Feb 1, 2005
    #2
    1. Advertising

  3. Andrew Price wrote:
    > <%
    > include myFileName
    > %>

    You are pretty close. The include syntax is
    <!--#include file="pageToInclude.aspx"-->

    BTW: Fun to see the ASP+ was the name of ASP.NET at an early stage. This
    is why the file extension is ASPX the X is a + sign rotated 45 degrees.

    Anders Norås
    http://dotnetjunkies.com/weblog/anoras/
     
    =?ISO-8859-1?Q?Anders_Nor=E5s?=, Feb 1, 2005
    #3
  4. Andrew Price

    teknohippy Guest

    On Tue, 01 Feb 2005 11:17:39 +0100, Anders Norås
    <> wrote:

    >Andrew Price wrote:
    >> <%
    >> include myFileName
    >> %>

    >You are pretty close. The include syntax is
    ><!--#include file="pageToInclude.aspx"-->
    >
    >BTW: Fun to see the ASP+ was the name of ASP.NET at an early stage. This
    >is why the file extension is ASPX the X is a + sign rotated 45 degrees.
    >
    >Anders Norås
    >http://dotnetjunkies.com/weblog/anoras/


    Will that work programitically with the OPs variable, it certainly
    wouldn't in ASP classic I don't think, though you could always
    Server.Execute you way out of it if I recall correctly.

    I

    --
    Iain Norman | http://www.eliteforum.org
     
    teknohippy, Feb 1, 2005
    #4
  5. Andrew Price

    Andrew Price Guest

    but can the

    <!--#include file="pageToInclude.aspx"-->

    be a variable name

    I got that far before in ASP I just wondereed if in ASP.NET they allowed you
    to dynamically include a file, ie in Coldfusion it is possible to

    <cfset myVariable = "pagename.cfm">

    <cfinclude template="#myVariable#">

    this would then include the name of the file defined in the variable, can
    this be done

    Andrew

    PS. Thanks for explaining about ASP, ASPX, ASP+ and ASP.NET now i get it !!!


    "Anders Norås" <> wrote in message
    news:...
    > Andrew Price wrote:
    >> <%
    >> include myFileName
    >> %>

    > You are pretty close. The include syntax is
    > <!--#include file="pageToInclude.aspx"-->
    >
    > BTW: Fun to see the ASP+ was the name of ASP.NET at an early stage. This
    > is why the file extension is ASPX the X is a + sign rotated 45 degrees.
    >
    > Anders Norås
    > http://dotnetjunkies.com/weblog/anoras/
     
    Andrew Price, Feb 1, 2005
    #5
  6. Andrew Price

    Andrew Price Guest

    How do you mean ?
    can you explain..
    Andrew
    "Patrice" <> wrote in message
    news:%23R6%...
    > This is <!--#include file="test.aspx"-->
    >
    > That said it is condisered as legacy. In ASP.NET, it is likely better to
    > use
    > a user control... (.ascx file)
    >
    > Patrice
    >
    > --
    >
    > "Andrew Price" <> a écrit dans le message
    > de
    > news:CjILd.462$...
    >> Hi I am very new to ASP+, i have a background in Coldfusion and ASP.
    >>
    >> Anyway what i want to do is include a file set by a varianle so
    >>
    >> apologies for the phsedo like code....
    >> <%
    >> dim myFileName
    >> myFileName = 'pageToInclude.aspx'
    >> %>
    >>
    >> <html>
    >> <body>
    >> ..
    >> ...
    >> <%
    >> include myFileName
    >> %>
    >>
    >> </body>
    >> </html>
    >>
    >>
    >> anyone know, or can point me in the direction of some useful tutorials
    >>
    >> thankyou
    >>
    >> Andrew
    >>
    >>

    >
    >
     
    Andrew Price, Feb 1, 2005
    #6
  7. Andrew Price

    Patrice Guest

    It really depends on what you are after.

    You could use :
    - User controls (ASCX files). Basically this is a page fragment that can
    include both HTML to define its appearence and code so that you can expose
    functionality and behavoir to the hosting page
    For details, see :
    http://msdn.microsoft.com/library/d...us/cpguide/html/cpconwebformsusercontrols.asp

    If this is to provide basic functionality on each page you could also either
    hook the BeginRequest/EndRequest event or inheriting from a base page
    providing common capabilities etc...

    Go for include for a quick port but you may want to check other available
    options if this is a new app...

    Patrice

    --

    "Andrew Price" <> a écrit dans le message de
    news:cNKLd.144$...
    > How do you mean ?
    > can you explain..
    > Andrew
    > "Patrice" <> wrote in message
    > news:%23R6%...
    > > This is <!--#include file="test.aspx"-->
    > >
    > > That said it is condisered as legacy. In ASP.NET, it is likely better to
    > > use
    > > a user control... (.ascx file)
    > >
    > > Patrice
    > >
    > > --
    > >
    > > "Andrew Price" <> a écrit dans le message
    > > de
    > > news:CjILd.462$...
    > >> Hi I am very new to ASP+, i have a background in Coldfusion and ASP.
    > >>
    > >> Anyway what i want to do is include a file set by a varianle so
    > >>
    > >> apologies for the phsedo like code....
    > >> <%
    > >> dim myFileName
    > >> myFileName = 'pageToInclude.aspx'
    > >> %>
    > >>
    > >> <html>
    > >> <body>
    > >> ..
    > >> ...
    > >> <%
    > >> include myFileName
    > >> %>
    > >>
    > >> </body>
    > >> </html>
    > >>
    > >>
    > >> anyone know, or can point me in the direction of some useful tutorials
    > >>
    > >> thankyou
    > >>
    > >> Andrew
    > >>
    > >>

    > >
    > >

    >
    >
     
    Patrice, Feb 1, 2005
    #7
  8. Hi andrew,

    > but can the
    >
    > <!--#include file="pageToInclude.aspx"-->
    >
    > be a variable name


    You really need to bone up on object-oriented programming. ASP is
    procedural; ASP.Net is object-oriented. The question you're asking is
    similar to asking "how do I double-clutch an automatic transmission?" The
    answer is "you don't." You're working with objects, events, and
    multi-threading now. The whole programming paradigm is different.

    --
    HTH,

    Kevin Spencer
    Microsoft MVP
    ..Net Developer
    Neither a follower nor a lender be.

    "Andrew Price" <> wrote in message
    news:4NKLd.143$...
    > but can the
    >
    > <!--#include file="pageToInclude.aspx"-->
    >
    > be a variable name
    >
    > I got that far before in ASP I just wondereed if in ASP.NET they allowed
    > you
    > to dynamically include a file, ie in Coldfusion it is possible to
    >
    > <cfset myVariable = "pagename.cfm">
    >
    > <cfinclude template="#myVariable#">
    >
    > this would then include the name of the file defined in the variable, can
    > this be done
    >
    > Andrew
    >
    > PS. Thanks for explaining about ASP, ASPX, ASP+ and ASP.NET now i get it
    > !!!
    >
    >
    > "Anders Norås" <> wrote in message
    > news:...
    >> Andrew Price wrote:
    >>> <%
    >>> include myFileName
    >>> %>

    >> You are pretty close. The include syntax is
    >> <!--#include file="pageToInclude.aspx"-->
    >>
    >> BTW: Fun to see the ASP+ was the name of ASP.NET at an early stage. This
    >> is why the file extension is ASPX the X is a + sign rotated 45 degrees.
    >>
    >> Anders Norås
    >> http://dotnetjunkies.com/weblog/anoras/

    >
    >
     
    Kevin Spencer, Feb 1, 2005
    #8
  9. Andrew Price wrote:
    > but can the include (abridged) be a variable name

    No it cannot be a variable name. If you want to dynamically include
    predefined "parts" in an ASPX page I suggest, as others have done before
    me, you use user controls. User controls are contained in ASPX pages,
    and offer Web developers an easy way to reuse commonly used Web UI.
    User controls are similar to ASPX pages, but they have a different page
    declaration and their extension is ASCX.
    To get started creating user controls, read the tutorial at
    http://www.asp101.com/lessons/usercontrols.asp

    Anders Norås
    http://dotnetjunkies.com/weblog/anoras/
     
    =?ISO-8859-1?Q?Anders_Nor=E5s?=, Feb 1, 2005
    #9
  10. Andrew Price

    Andrew Price Guest

    Thankyou for your help

    Andrew
    "Anders Norås" <> wrote in message
    news:%...
    > Andrew Price wrote:
    >> but can the include (abridged) be a variable name

    > No it cannot be a variable name. If you want to dynamically include
    > predefined "parts" in an ASPX page I suggest, as others have done before
    > me, you use user controls. User controls are contained in ASPX pages, and
    > offer Web developers an easy way to reuse commonly used Web UI.
    > User controls are similar to ASPX pages, but they have a different page
    > declaration and their extension is ASCX.
    > To get started creating user controls, read the tutorial at
    > http://www.asp101.com/lessons/usercontrols.asp
    >
    > Anders Norås
    > http://dotnetjunkies.com/weblog/anoras/
     
    Andrew Price, Feb 1, 2005
    #10
  11. Andrew Price

    Andrew Price Guest

    Thankyou for your help

    Andrew
    "Kevin Spencer" <> wrote in message
    news:...
    > Hi andrew,
    >
    >> but can the
    >>
    >> <!--#include file="pageToInclude.aspx"-->
    >>
    >> be a variable name

    >
    > You really need to bone up on object-oriented programming. ASP is
    > procedural; ASP.Net is object-oriented. The question you're asking is
    > similar to asking "how do I double-clutch an automatic transmission?" The
    > answer is "you don't." You're working with objects, events, and
    > multi-threading now. The whole programming paradigm is different.
    >
    > --
    > HTH,
    >
    > Kevin Spencer
    > Microsoft MVP
    > .Net Developer
    > Neither a follower nor a lender be.
    >
    > "Andrew Price" <> wrote in message
    > news:4NKLd.143$...
    >> but can the
    >>
    >> <!--#include file="pageToInclude.aspx"-->
    >>
    >> be a variable name
    >>
    >> I got that far before in ASP I just wondereed if in ASP.NET they allowed
    >> you
    >> to dynamically include a file, ie in Coldfusion it is possible to
    >>
    >> <cfset myVariable = "pagename.cfm">
    >>
    >> <cfinclude template="#myVariable#">
    >>
    >> this would then include the name of the file defined in the variable, can
    >> this be done
    >>
    >> Andrew
    >>
    >> PS. Thanks for explaining about ASP, ASPX, ASP+ and ASP.NET now i get it
    >> !!!
    >>
    >>
    >> "Anders Norås" <> wrote in message
    >> news:...
    >>> Andrew Price wrote:
    >>>> <%
    >>>> include myFileName
    >>>> %>
    >>> You are pretty close. The include syntax is
    >>> <!--#include file="pageToInclude.aspx"-->
    >>>
    >>> BTW: Fun to see the ASP+ was the name of ASP.NET at an early stage. This
    >>> is why the file extension is ASPX the X is a + sign rotated 45 degrees.
    >>>
    >>> Anders Norås
    >>> http://dotnetjunkies.com/weblog/anoras/

    >>
    >>

    >
    >
     
    Andrew Price, Feb 1, 2005
    #11
    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. Luis Esteban Valencia Muñoz
    Replies:
    3
    Views:
    1,421
    Scott Allen
    Jun 4, 2005
  2. Replies:
    12
    Views:
    848
    John Harrison
    Mar 2, 2007
  3. =?Utf-8?B?QW5hbmRoaQ==?=

    How to call a ASP.net file from ASP file

    =?Utf-8?B?QW5hbmRoaQ==?=, Apr 19, 2007, in forum: ASP .Net
    Replies:
    1
    Views:
    322
    Steve C. Orr [MCSD, MVP, CSM, ASP Insider]
    Apr 19, 2007
  4. Rainer Heynke
    Replies:
    3
    Views:
    398
    James Kanze
    Sep 12, 2008
  5. Tomasz Ludwiniak

    Execute ASP file from ASP file

    Tomasz Ludwiniak, Oct 29, 2003, in forum: ASP General
    Replies:
    3
    Views:
    146
    Bob Barrows
    Oct 29, 2003
Loading...

Share This Page