[thelist] .asp "if pagename [this]..."
Russ
russ at unrealisticexpectations.com
Fri May 28 06:46:45 CDT 2004
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>
Voila!
Thanks for the responses.
Russ
> --------------------------------
> I've set up my
> navigation inside of include files, and I'm really not
> wanting to change
> this, so I'm wondering if there's a way to say:
> <% If pagename is [current pagename]
> Then style = [LI style2]
> Else
> Style = [LI style1] %>
> --------------------------------
>
> I am guessing you're talking "classic" ASP not .NET. Also
> guessing that
> you're not using a database to establish the pagename var.
> So: you can use
> the ServerVariables collection of the Request object for this[1]. For
> example you have www.example.com/home/blah.asp which has include file
> /inc/nav.inc.asp, which has the statement Response.Write
> Request.ServerVariables("SCRIPT_NAME"). If you request
> blah.asp with your
> browser, the output will be "/home/blah.asp" - i.e. the name
> of the running
> script.
>
> I imagine the MS gurus on the list will give more details...
> oh, too late,
> Ken already gave an msdn link. :)
>
> [1]
> http://www.devguru.com/Technologies/asp/quickref/request_serve
rvariables.htm
l
More information about the thelist
mailing list