473,396 Members | 1,895 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Css Style active link

Fary4u
273 100+
using asp while condition
how can i write perticular link as a selected value ?

Expand|Select|Wrap|Line Numbers
  1. <a class="mainlevel" href="p.asp?strCat=<%= strcat%>">
  2. <%= strcat %></a>
  3.  
using CSS style sheet

Expand|Select|Wrap|Line Numbers
  1. A.mainlevel:link {
  2. DISPLAY: block
  3. }
  4. A.mainlevel:visited {
  5. DISPLAY: block; TEXT-DECORATION: none
  6. }
  7. A.mainlevel:active {
  8. BORDER-LEFT: 5px; 
  9. }
  10.  
Aug 19 '10 #1
1 3638
azrar
11
Assuming you are creating a menu with multiple links

There are two ways you can do it.

First way is completely ASP:
Expand|Select|Wrap|Line Numbers
  1.  
  2. ' assuming you are already displaying the category based on a value in the querystring
  3. current_cat_id = request.QueryString("cat")
  4.  
  5. DO WHILE NOT rsLinks.eof
  6.   cat_id = rs("cat_id").value
  7.   cat_title = rs("cat_title").value
  8.   css_class = ""
  9.   If Cstr(cat_id) = Cstr(current_cat_id) Then
  10.     css_class = " active" 'note the space, it is needed to separate the two class names (mainlevel and active)
  11.   End IF
  12.   response.write "<a href='p.asp?cat=" & rs("cat").value & "' class='mainlevel" & css_class & "'>" & cat_title & "</a>"
  13.   rs.movenext
  14. Loop
  15.  
Note that you would need to make an "active" class in your CSS file. Like this:

a.active {border-left:5px solid #333;}


The other way is clever combo of ASP and CSS, but has some drawbacks.

Include the following CSS declaration in your ASP page:
Expand|Select|Wrap|Line Numbers
  1. a[href='<%=request.ServerVariables("SCRIPT_NAME")%>'] {border-left:5px solid #333;}
  2.  
This method only works if you are linking putting the full virtual path in your links (which is a good practice to do anyway). Meaning, if your links point to "/p.asp" instead of "p.asp". Also it will not work in IE 6.
Aug 19 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

36
by: Peter Brause | last post by:
Hello, my stylesheet shows different colors for visited, active and hovered links. It works fine in IE 6, but in Opera 7 the color for the active link (red background) is never shown. How to...
4
by: Laiverd.COM | last post by:
Posted this in the MM Dreamweaver group also, but then found this newsgroup, in which I hope someone knows the answer What I'd like to do is define a specific style for a link that is in a...
6
by: Carla | last post by:
hi people, I have a little problem that I can't solve with css and i was wondering if you could help me. I have 4 links, I want that when I click/mouseover in the link 1, it turns to a color...
4
by: crhaynes | last post by:
I'm having trouble with my CSS. My links are black, my hover is orange and my active link is red. When I select a link it turns red but i does not retain that color when the selected page loads. ...
2
by: paulmac106 | last post by:
Hi, I have a menu control that has two Menu choices One is "View History Items" the second is "PDA" My problem is as you roll the mouse over the menu options, the second one works only...
2
by: David W | last post by:
I need to include a style sheet link in the aspx page based on what user they are. Basically this functionality, but using code behind. Any idea how to change this line to code behind? This...
1
beacon
by: beacon | last post by:
I'm looking to reset the visited link color once another link is selected. Also, once that link takes me to a particular page, I want the font-weight for that page to be bold to indicate that it's...
2
by: Garima12 | last post by:
There is htm page. In its body I am calling a class from stylesheet called TaskbarStyle(classname). Now I want to change the color of hyperlink in this page as well as their active link color. I am...
1
by: Sarah Hammond | last post by:
Hello There, I am using jquery Spry Sliding panels for a new site i am working on. I am looking to style similarly to this example in particular I am trying to find a way to give the navigation...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.