473,320 Members | 2,112 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Conditioning include files ?

I want to condition what include files are included in an web page (.aspx).
Something like:

if (condition1)
{
<!-- #Include File='file1.htm' -->
}
else if (condition2)
{
<!-- #Include File='file2.htm' -->
}
else
{
<!-- #Include File='file3.htm' -->
}

Is this posible in ASP.NET ?
What is the correct way to write this code ?
Nov 17 '05 #1
7 1514
Not like this. Include file processing is done BEFORE any script on the page
is run. It needs to be becuase most include files contain code that needs to
be part of the page.

In ASP.Net however, you do have lots of other options. For example,
encapsulating the content in a user control then adding the control to the
page, or a placeholder in the page like

if(condition1)
myPlaceholder.controls.add(myControl1);
else if (condition2)
myPlaceholder.controls.add(myControl2);

etc...
There are tons of different ways to do this, but SSI is not the way to
go if you need conditional includes because the include is always before any
script that can be used for conditional programming.

Hope this helps,
Mark Fitzpatrick
Microsoft MVP - FrontPage

"Andre" <an***@yahoo.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
I want to condition what include files are included in an web page (.aspx). Something like:

if (condition1)
{
<!-- #Include File='file1.htm' -->
}
else if (condition2)
{
<!-- #Include File='file2.htm' -->
}
else
{
<!-- #Include File='file3.htm' -->
}

Is this posible in ASP.NET ?
What is the correct way to write this code ?

Nov 17 '05 #2
Include Files are generally not used, as they are not object-oriented.
Secondly, includes are pre-processor instructions, and it has never been
possible to use them conditionally. I think you need to use User Controls
instead, and you can conditionally add or remove them from the page.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
http://www.takempis.com
Big Things are made up of
Lots of Little Things.

"Andre" <an***@yahoo.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
I want to condition what include files are included in an web page (.aspx). Something like:

if (condition1)
{
<!-- #Include File='file1.htm' -->
}
else if (condition2)
{
<!-- #Include File='file2.htm' -->
}
else
{
<!-- #Include File='file3.htm' -->
}

Is this posible in ASP.NET ?
What is the correct way to write this code ?

Nov 17 '05 #3
User DEFINED controls ?
You mean to define (create) my own control ?
"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:ul**************@tk2msftngp13.phx.gbl...
Include Files are generally not used, as they are not object-oriented.
Secondly, includes are pre-processor instructions, and it has never been
possible to use them conditionally. I think you need to use User Controls
instead, and you can conditionally add or remove them from the page.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
http://www.takempis.com
Big Things are made up of
Lots of Little Things.

"Andre" <an***@yahoo.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
I want to condition what include files are included in an web page

(.aspx).
Something like:

if (condition1)
{
<!-- #Include File='file1.htm' -->
}
else if (condition2)
{
<!-- #Include File='file2.htm' -->
}
else
{
<!-- #Include File='file3.htm' -->
}

Is this posible in ASP.NET ?
What is the correct way to write this code ?


Nov 17 '05 #4
My problem:

I have a page (aspx) that contains, among other things, a table cel (<td>)
in which I have to display the contents of 1 of 3 files that contain HTML
code, that are stored on the disk, depending on which button the user
clicks.

At first I thought that using include files would be the best solution, but
it seems not.

Anyone knows what would be the easyest way to do this ?

(I have been programing php and windows forms up until now and this is my
first project with web forms so I don't have much experience with this)


"Mark Fitzpatrick" <ma******@fitzme.com> wrote in message
news:#n**************@TK2MSFTNGP12.phx.gbl...
Not like this. Include file processing is done BEFORE any script on the page is run. It needs to be becuase most include files contain code that needs to be part of the page.

In ASP.Net however, you do have lots of other options. For example,
encapsulating the content in a user control then adding the control to the
page, or a placeholder in the page like

if(condition1)
myPlaceholder.controls.add(myControl1);
else if (condition2)
myPlaceholder.controls.add(myControl2);

etc...
There are tons of different ways to do this, but SSI is not the way to
go if you need conditional includes because the include is always before any script that can be used for conditional programming.

Hope this helps,
Mark Fitzpatrick
Microsoft MVP - FrontPage

"Andre" <an***@yahoo.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
I want to condition what include files are included in an web page

(.aspx).
Something like:

if (condition1)
{
<!-- #Include File='file1.htm' -->
}
else if (condition2)
{
<!-- #Include File='file2.htm' -->
}
else
{
<!-- #Include File='file3.htm' -->
}

Is this posible in ASP.NET ?
What is the correct way to write this code ?


Nov 17 '05 #5
My problem:

I have a page (aspx) that contains, among other things, a table cel (<td>)
in which I have to display the contents of 1 of 3 files that contain HTML
code, that are stored on the disk, depending on which button the user
clicks.

At first I thought that using include files would be the best solution, but
it seems not.

Anyone knows what would be the easyest way to do this ?

(I have been programing php and windows forms up until now and this is my
first project with web forms so I don't have much experience with this)

"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in message
news:ul**************@tk2msftngp13.phx.gbl...
Include Files are generally not used, as they are not object-oriented.
Secondly, includes are pre-processor instructions, and it has never been
possible to use them conditionally. I think you need to use User Controls
instead, and you can conditionally add or remove them from the page.

--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
http://www.takempis.com
Big Things are made up of
Lots of Little Things.

"Andre" <an***@yahoo.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
I want to condition what include files are included in an web page

(.aspx).
Something like:

if (condition1)
{
<!-- #Include File='file1.htm' -->
}
else if (condition2)
{
<!-- #Include File='file2.htm' -->
}
else
{
<!-- #Include File='file3.htm' -->
}

Is this posible in ASP.NET ?
What is the correct way to write this code ?


Nov 17 '05 #6
It's very strange what you are trying to do. But I suggest
you to read your HTML files with the System.IO namespace
(very simple). and then display the content of one of your
seleted file in a asp:placeholder.

if (condition1)
{
// read 'file1.htm' with system.io functions (you will
find many example in msdn)
placeHolder.controls.add(new litteral(<your file
content as string>)

}
else if (condition2)
{
<!-- #Include File='file2.htm' -->
}
else
{
<!-- #Include File='file3.htm' -->
}

-----Original Message-----
My problem:

I have a page (aspx) that contains, among other things, a table cel (<td>)in which I have to display the contents of 1 of 3 files that contain HTMLcode, that are stored on the disk, depending on which button the userclicks.

At first I thought that using include files would be the best solution, butit seems not.

Anyone knows what would be the easyest way to do this ?

(I have been programing php and windows forms up until now and this is myfirst project with web forms so I don't have much experience with this)
"Kevin Spencer" <ke***@DIESPAMMERSDIEtakempis.com> wrote in messagenews:ul**************@tk2msftngp13.phx.gbl...
Include Files are generally not used, as they are not object-oriented. Secondly, includes are pre-processor instructions, and it has never been possible to use them conditionally. I think you need to use User Controls instead, and you can conditionally add or remove them from the page.
--
HTH,

Kevin Spencer
Microsoft MVP
.Net Developer
http://www.takempis.com
Big Things are made up of
Lots of Little Things.

"Andre" <an***@yahoo.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
> I want to condition what include files are included
in an web page (.aspx).
> Something like:
>
> if (condition1)
> {
> <!-- #Include File='file1.htm' -->
> }
> else if (condition2)
> {
> <!-- #Include File='file2.htm' -->
> }
> else
> {
> <!-- #Include File='file3.htm' -->
> }
>
> Is this posible in ASP.NET ?
> What is the correct way to write this code ?
>
>


.

Nov 17 '05 #7
Andre,

I think what you want to do will work just fine. You could use a combination
of dynamically loaded user controls and a placeholder tag to do exactly what
you want.

My own website is a single page into which user controls (the new include
file) are loaded into a main content area using a placeholder. I have the
sample code of how to do so in the site's code library. Just go to
www.aboutfortunate.com and then click the code library link. Use the search
box there to search for: "Dynamically load user control" or something
similar and you'll find the code you need to do this.

If you have any questions about it feel free to email me.

Sincerely,

--
S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
"Andre" <an***@yahoo.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
I want to condition what include files are included in an web page (.aspx). Something like:

if (condition1)
{
<!-- #Include File='file1.htm' -->
}
else if (condition2)
{
<!-- #Include File='file2.htm' -->
}
else
{
<!-- #Include File='file3.htm' -->
}

Is this posible in ASP.NET ?
What is the correct way to write this code ?

Nov 17 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Chad Scharf | last post by:
I have a legacy ASP application running on IIS 6.0 (Windows Server 2003 Web Edition) that is throwing an error when processesing a certain asp page that has about 200 or so include directives. ...
0
by: Tom Lee | last post by:
Hi, I'm new to .NET 2003 compiler. When I tried to compile my program using DEBUG mode, I got the following errors in the C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7 \include\xdebug...
7
by: mescaline | last post by:
Hi, Suppose a_file.cpp contains a function a_function() Now to include it in main_file.cpp I just do #include "a_file.cpp" and I'm all set. i recently came across this seemingly roundabout...
6
by: atv | last post by:
Alright, i have some questions concerning include files en global variables.I hope someone is willing to answer these. 1).Why is it that if i define a global variable in a file, say main.c, and...
5
by: David Mathog | last post by:
One thing that can make porting C code from one platform to another miserable is #include. In particular, the need to either place the path to an included file within the #include statement or to...
1
by: Minh | last post by:
I've just installed VS.NET 2003 on my Athlon XP 1800+. However I couldn't get any project with STL includes to compile even if I create a new empty project (and added #include <string>). It gave me...
1
by: ya man | last post by:
when i use #include <iostream.h> in some files i get lots of error messages of the kind 'ambiguous symbol this is solved when i use #include <iostream why is that ? and can i use #include...
2
by: key9 | last post by:
Hi all look at the organize tree main.c ------ #include lib_adapter.c main() { foo();
16
by: Chris Shearer Cooper | last post by:
In our Visual Studio 2005 application, we have several of our application's H files that are #included into stdafx.h. What is odd, is that when we change those application H files, VS2005...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.