Inluding a file in ASP+

A

Andrew Price

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
 
P

Patrice

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
 
?

=?ISO-8859-1?Q?Anders_Nor=E5s?=

Andrew said:
<%
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/
 
T

teknohippy

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
 
A

Andrew Price

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 !!!
 
A

Andrew Price

How do you mean ?
can you explain..
Andrew
Patrice said:
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
 
P

Patrice

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

--
 
K

Kevin Spencer

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.
 
?

=?ISO-8859-1?Q?Anders_Nor=E5s?=

Andrew said:
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/
 
A

Andrew Price

Thankyou for your help

Andrew
Anders Norås said:
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/
 
A

Andrew Price

Thankyou for your help

Andrew
Kevin Spencer said:
Hi andrew,


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.
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top