Forum Moderators: open

Message Too Old, No Replies

Active Hyper Links

What is the best way to change active link

         

bluesquirel

10:04 am on Mar 26, 2005 (gmt 0)

10+ Year Member



I have setup a CSS Id called active and based on the value of foo in the querystring i want one tab to be Active.

Is this the best way to do it , it seems a bit long winded.

<%@ Control Explicit="True" Language="VB" Debug="TRUE" %>
<%
Dim MySelectedItem As Integer
MySelectedItem = cint(Request.QueryString("foo"))

%>
<li id="active"><a href="index.aspx" id="current">Home</a></li>

<%
If MySelectedItem = "1" Then
Response.Write("<li id=active><a href=index.aspx?foo=1 id=current>The Best Of</a></li>")
Else
Response.Write("<li><a href=index.aspx?foo=1>The Best Of</a></li>")
End If
%>

<li><a href="index.aspx?foo=3">Events</a></li>
<li><a href="index.aspx?foo=4">News</a></li>
<li><a href="index.aspx?foo=5">Advertise</a></li>
<li><a href="index.aspx?foo=6">Contact Us</a></li>

Thanks in advance

Dave

TheNige

8:35 pm on Mar 28, 2005 (gmt 0)

10+ Year Member



Easier way might be to create a quick function.

<li><a href="index.aspx?foo=3" <%=IsActive(3)%>>Events</a></li>

public function IsActive(ByVal SelectedItem as integer, ByVal ID as Integer) as string
if SelectedItem = ID then
return "ID=Active"
end if
end function