473,667 Members | 2,548 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1542
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.c ontrols.add(myC ontrol1);
else if (condition2)
myPlaceholder.c ontrols.add(myC ontrol2);

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.co m> wrote in message
news:%2******** ********@tk2msf tngp13.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.co m> wrote in message
news:%2******** ********@tk2msf tngp13.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***@DIESPAMM ERSDIEtakempis. com> wrote in message
news:ul******** ******@tk2msftn gp13.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.co m> wrote in message
news:%2******** ********@tk2msf tngp13.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******@fitzm e.com> wrote in message
news:#n******** ******@TK2MSFTN GP12.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.c ontrols.add(myC ontrol1);
else if (condition2)
myPlaceholder.c ontrols.add(myC ontrol2);

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.co m> wrote in message
news:%2******** ********@tk2msf tngp13.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***@DIESPAMM ERSDIEtakempis. com> wrote in message
news:ul******** ******@tk2msftn gp13.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.co m> wrote in message
news:%2******** ********@tk2msf tngp13.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.con trols.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***@DIESPAMM ERSDIEtakempis. com> wrote in messagenews:ul******* *******@tk2msft ngp13.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.co m> wrote in message
news:%2******** ********@tk2msf tngp13.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: "Dynamicall y 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.co m> wrote in message
news:%2******** ********@tk2msf tngp13.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
3284
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. We've checked the spelling, paths, include directives, and files individually and all of them work. We have also commented out random ones (4 or so at a time) and then the page works. It doesn't matter which ones we comment out, just so long as...
0
6117
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 file as folows. I need help to resolve them ASAP: cl /c /nologo /MDd /W3 /Od /GR /GM /Zi /GX /D "_DEBUG" /D " WIN32" /D "_W INDOWS" /D "_WINDLL" /D "_AFXDLL" /D "_MBCS" /D "_USRDLL" /
7
3545
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 way to do this in 3 steps: 1. Add in main_file.cpp
6
9574
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 i have also other functions defined in that file, i can use the global in all functions, but once i split up the rest of the function in other files, i cannot use the global? Isn't that strange, all the files compiled should be treated as one...
5
2506
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 very carefully define the order in which paths are searched with command line options on the compiler. Both can cause problems, especially when dealing with complex software distributions. It occurs ot me that by extending the C include...
1
7475
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 a bunch of "missing ;" errors. I did reinstall the whole thing a few times but it didn't work. Anyone have any idea? Thanks c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\xutility(862) :
1
4563
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 <iostream.h> in some way examples to the error messages c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\streamb.h(90): error C2872: 'ios' : ambiguous symbo c:\Program Files\Microsoft Visual Studio .NET\Vc7\include\streamb.h(90): error C2872:...
2
3528
by: key9 | last post by:
Hi all look at the organize tree main.c ------ #include lib_adapter.c main() { foo();
16
2375
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 doesn't trigger a rebuild of the entire app (or of anything, for that matter). Is this a setting somewhere? Thanks!
0
8457
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8883
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8563
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8646
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6203
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5675
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4372
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2013
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1778
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.