how to conditionally include html files in asp.net page

N

ningjun.wang

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
 
E

Eliyahu Goldin

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.
 

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,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top