473,670 Members | 2,527 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to conditionally include html files in asp.net page

I need to include to static html files in my asp.net page. The order of
include depend on query string. Here is the pseudo code

mypage.aspx:

<%
string mode = Request["mode"];
if (mode == "A") {
include("file1. html"); // How to do this?
include("filee2 .html");
} else {
include("file2. html");
include("filee1 .html");
}
%>

How can I do this? I heard some suggestion of using User controls and
PlaceHolder controls and do this in the code behind file. I just feel
that is overkill. Is there any simple way to do this in the aspx file
without using the code behind file?

I am new to ASP.NET, so please give me the code snippet with correct
syntax instead of pseudo code.

Thanks

Dec 15 '06 #1
1 4622
Asp.net is object-oriented rather than procedure-oriented. Instead of
manipulating the order of creation, you should rather manipulate with
properties like this:

control1([some property that affects the content])=[some code that returns
the content depending on mode]
control2([some property that affects the content])=[some code that returns
the content depending on mode]

Depending on your page layout and other considerations, you can use
placeholders, or iframes, or something else. You have quite a choice here.
In any case you have to be patient with asp.net and be ready to learn.
Possibly you should follow the suggestions you heard. Shortcuts usually lead
to incorrect or inefficient solutions.

--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
<ni**********@l exisnexis.comwr ote in message
news:11******** **************@ 73g2000cwn.goog legroups.com...
>I need to include to static html files in my asp.net page. The order of
include depend on query string. Here is the pseudo code

mypage.aspx:

<%
string mode = Request["mode"];
if (mode == "A") {
include("file1. html"); // How to do this?
include("filee2 .html");
} else {
include("file2. html");
include("filee1 .html");
}
%>

How can I do this? I heard some suggestion of using User controls and
PlaceHolder controls and do this in the code behind file. I just feel
that is overkill. Is there any simple way to do this in the aspx file
without using the code behind file?

I am new to ASP.NET, so please give me the code snippet with correct
syntax instead of pseudo code.

Thanks

Dec 17 '06 #2

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

Similar topics

2
1363
by: Sten Westerback | last post by:
Hi I'm considering using .asp to implement a selective inclusion of .htm files containing tables into a HTML code sent to browser from IIS. My question is if it is possible to make an .asp page that depending on two variables passed in the query (start-month and end-month) return to the browser a page that includes only files with names within the
3
1722
by: alwayswinter | last post by:
I currently have a form where a user can enter results from a genetic test. I also have a pool of summaries that would correspond to different results that a user would enter into the form. I ideally I would like to have the user enter their results and then have a master summary created with the different word or HTML files on submit. (condition 1 + condition 2 = combining/displaying corresponding HTML files) I've gotten as far as...
6
2114
by: tshad | last post by:
In my User control, I tried to do this: *************************************************************************** <Script runat="server"> Public ClientName As String = "<!-- #include file = ...\includes\StaffingHeaders.inc -->" </Script> <%=ClientName%> ****************************************************************************
2
1251
by: Craig | last post by:
Is there a way to conditionally include a file in the HTML? <TD> if x= 1 then <!--#INCLUDE FILE="../File1"--> else <!--#INCLUDE FILE="../File2"--> end if
2
4633
by: WisTex | last post by:
I've come across a very weird problem. Virtual includes work on all my ASP pages on the entire website, including those in subdirectories, yet they won't work on a particular page I created, even though the virtual include statement is copy & pasted exactly as it appears on the working pages. What would cause virtual includes to work in one page on a website, but not on another? Error Message: Microsoft VBScript runtime error...
3
1594
by: Larry | last post by:
Hi, I need a method to dynamically include a server side include in my asp.net page. The problem is, the include file contains asp.net controls, and I can't find a way to get the controls to render. HISTORY I have an active website. I have about 100 include files that are just html text. In .aspx page, I have the following:
2
1300
by: Felix | last post by:
Hello, I use a #define like WITH_MYSTUFF to conditionally compile code within #ifdef WITH_MYSTUFF. I would now like the same define to conditionally link with a library. In the linker settings of VS.NET 2003 I have 'Input -> Additional Dependencies' where I can add my .lib files the linker should use. How do I tell the linker (by a macro ?) somthing like this:
7
13132
by: lister | last post by:
Hi, I have a situation where I have a large block of HTML code that is conditionally displayed. In effect I have: html page some html <?php if (bShowBlock)
4
7121
by: Kevin G. | last post by:
Hello all, I have a flat HTML page with 3 distinct HTML tables, and I'm trying to randomly display the tables when the page loads, without repeating. My idea is to use the PHP include() function to pull in the page content. So what I've done so far was broke the full page down into 3 static HTML files, each containing one of the tables. Then in the main index page where I want to display the code randomly, I created a variable
0
8466
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
8896
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...
0
8810
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8659
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...
0
7410
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6211
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
4208
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4387
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2798
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.