Forum Moderators: open
I may have to convert a php site to ASP. I have always used php to include certain pages into my main index page.
E.g
<?
if ($page=="") {include("nav/navigation_index.php");
};
if ($page=="home") include("nav/navigation_index.php");
};
if ($page=="page1") include("nav/nav_page1.php");
};
?>
The links would then have index.php?page=home or index.php?page=page1 etc
Could someone tell me how to do this using ASP or point me the right direction as for now I do not need to learn a great deal.
Thanks in advance, to anyone who is able to help.
if (page_name = "home") then
Response.write "<!--#include file='nav/navigation_index.asp'-->"
elseif (page_name = "page1") then
Response.write "<!--#include file='nav/nav_page1.asp'-->"
else
Response.write "<!--#include file='nav/navigation_index.asp'-->"
end if
%>
I'm currently switching to PHP from ASP so I feel your pain. Just remember that insided of your double quotes you should use single quotes so that you don't accidently end your statement.
In order to include a page with ASP, yes you have to use:
<!--#include file="nav/navigation_index.asp"-->
The catch is that the #include directive is a server-side call, and it's processed before any ASP code. So that means you cannot use an IF...END IF statement to choose whether or not to use it.
Here's an idea of how ASP code is processed by the server/browser:
1st - Server Side Includes
2nd - ASP
3rd - HTML (processed by browser)
A little more info here [w3schools.com].
<%
dim something
if page_name = "home" then
something = "1"
elseif page_name = "page1" then
something = "2"
end if
Select Case Something
Case 1
Server.Execute "nav/navigation_index.php"
Case 2
Server.Execute "nav/nav_page1.php"
Case Else
Server.Execute "nav/navigation_index.php"
End Select
%>