[thelist] .asp "if pagename [this]..."
Sarah Sweeney
mr.sanders at designshift.com
Fri May 28 08:48:35 CDT 2004
Russ wrote:
> In the event that there are other newbies in .asp trying to figure
> something similar out, I've come up with a simple, although probably not
> the "prettiest" way to do this:
>
> On every page (actually in a header include), I define that actual
> pagename like this:
>
> <%
> pagename=mid(Request.ServerVariables("URL"),
> instrrev(Request.ServerVariables("URL"), "/")+1)
> %>
>
> Then, in my navigation include, I check for the page name and output a
> style based upon that result:
>
> <ul>
> <% if pagename = "company.asp" then classname = "li2" else
> classname = "li1" %>
> <li class="<% Response.Write(classname) %>"><a
> href="company.asp">Overview</a></li>
> </ul>
There is a somewhat more elegant way to handle this:
- alter the code where you set the pagename variable so that it does not
include the ".asp"
- use the pagename variable as the id attribute in the <body> tag, like
this:
<body id="<%= pagename %>">
- no need to include the conditional statements in your navigation
include now, just use this in your CSS:
body#company li { ... }
body#classname li { ... }
--
Sarah Sweeney
http://hardedge.ca me, blog, pictures, etc
http://sarah.designshift.com web development, programming, etc
More information about the thelist
mailing list