Ed,
Lee is correct when he states that you are trying to do dynamic includes.
One thing you may or may not be aware of is that ALL of those pages are loaded into the calling page BEFORE the ASP parser interprets the ASP code. This means that if you have 10 pages inside 10 select case statements, your server will be loading all 10 of them, putting the content (e.g. code) from each of them as a replacement of the <!--#include...> tag, then once it has this big long script, it executes the code.
I doubt this is what you expected... most people assume that it will only include the content of the file if the condition is met... but this is not how SSI and ASP works. SSI is called first, then ASP code is executed once all the content has been combined. (hence why it is not actually part of the ASP code, and can be used in a HTML file.)
There are ways to emulate dynamic includes, for example the Server.Transfer or Server.Execute functions or FSO and Execute()
If you already understand that, and are happy with that design then simply ignore us, Lee and I are simply pointing out a common misconception that's not usually preferred behaviour.
In regards to your stated problem, this works:
Default.asp
Code:
<%
if Request.QueryString("x") = "form" then
%>
<!--#include virtual="/test/form.asp" -->
<%
else
%>
<!--#include virtual="/test/form2.asp" -->
<%
end if
%>
form.asp
Code:
<html>
<head>
</head>
<body>
<form method="post" action="./?x=result">
<input type="text" name="test" />
<input type="Submit" value="Submit" />
</form>
</body>
</html>
form2.asp
Code:
<%
Response.Write(Request.Form("test"))
%>
Try it for yourself and see. Then look at your own code to see what is different.
Also, your example code puts the <!--#include...> inside the ASP code... this is not correct, and will not work, hence I have refactored your example to put it outside the <% %> tags.
So, what exactly is the code in these included files ? maybe that is the source of your problem - but we have no idea what that code actually looks like, so you're going to have to share if you want any more advice.
A smile is worth a thousand kind words. So smile, it's easy! 