I have too many pages. when I change something on menu I have to change every page. I don't want to write navigation menu for every page again and again, so I used include file navigation menu. I don't know asp too much but I want to use it.
navigation.inc sample:
<a class="nav-link active" href="link1.asp">Link 1</a>
<a class="nav-link" href="link2.asp">Link 2</a>
there is a class called active. paints the navigation link in blue. when I navigate to link2 page I want to do this
<a class="nav-link" href="link1.asp">Link 1</a>
<a class="nav-link active" href="link2.asp">Link 2</a>
how can I that with asp classic? I tried something but it's looks ridiculous. is there any easy and professional way?
thanks for all information.
Add an include in all your pages :
<%
...
%>
<!--#include file="nav.asp"-->
<%
...
%>
And your nav.asp
page :
<%
curPageName = Request.ServerVariables("URL")
if curPageName = "link1.asp" then
%>
<a class="nav-link active" href="link1.asp">Link 1</a>
<a class="nav-link" href="link2.asp">Link 2</a>
<%
end if
if curPageName = "link2.asp" then
%>
<a class="nav-link" href="link1.asp">Link 1</a>
<a class="nav-link active" href="link2.asp">Link 2</a>
<%
end if
%>
You can simplify your nav.asp
page by adding a custom iif
function to vbscript
<%
function iif(condition, t, f)
if condition then
iif = t
else
iif = f
end if
end function
curPageName = Request.ServerVariables("URL")
%>
<a class="nav-link<%=iif(curPageName = "link1.asp", " active", "")%>" href="link1.asp">Link 1</a>
<a class="nav-link<%=iif(curPageName = "link2.asp", " active", "")%>" href="link2.asp">Link 2</a>