473,770 Members | 4,552 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Css Style active link

Fary4u
273 Contributor
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 3658
azrar
11 New Member
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
3897
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 explain this? Here is my code: (code optimization will be done later) 1. The HTML file <!doctype html public "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head>
4
2927
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 specific row. This works, but has a drawback: tr.homeLatestNews a.newsLink { font-weight: bold; display: block; }
6
15900
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 a, then when I click/mouseover over the link 2, it turns to a color b and the link 1 turns to the normal link color again. (an so with the other links). Is this possible with CSS?
4
20227
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. Is i possible to retain that color? My navigation that i'm trying to get this corrected on is server-side include
2
1881
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 if your mouse is actually over the text "PDA". Since it
2
1963
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 breaks once we include an AJAX control on the page. <head runat="server"> <link href="/textfiles/style<%= Session("partner_id") %>.css" rel="stylesheet" type="text/css">
1
4116
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 the page you're looking at. Now, if the links have never been visited before, they are blue. If you hover over the links they turn light blue. I want the user to be able to select the link and it take you to that page. On that page, I want the link...
2
2617
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 calling 2 stylesheets on this htm page. code of htm page: <BODY class="TaskbarStyle" TEXT="Black" bottommargin="0" centermargin="0" rightmargin="0" topmargin="0"> code of stylsheet which contains TaskbarStyle class; .TaskbarStyle { ...
1
2818
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 links (which will eventually be imgs) an active state (whichever link is currently selected-I wish it to have a different image and same for mouseover) as on the coda website. I'm quite new to javascript, and having read similar articles on the forum...
0
9439
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10237
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10071
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10017
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9882
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7431
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6690
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
3589
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2832
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.