We help IT Professionals succeed at work.

a tag

JCWEBHOST
JCWEBHOST asked
on
Hey guys i need to apply css to a a ref in c#

i know an a tag has active class and hover

#left_menu a
{
      color: #FFFFFF;
      text-decoration: none;
      font-size: 14px;
      line-height: 36px;
      background-image: url(         '../images/menubox/menu.png' );
      background-repeat: no-repeat;
      padding: 0px 10px 0px 10px;
      margin: 0px;
      width: 190px;
      height: 36px;
      display: inline-block;
      text-shadow: #FFFFFF 0px 0px 1px;
}

#left_menu a:hover
{
      color: #FFFFFF;
      text-decoration: none;
      font-size: 14px;
      line-height: 36px;
      background-image: url(    '../images/menubox/menu_o.png' );
      background-repeat: no-repeat;
      padding: 0px 10px 0px 10px;
      margin: 0px;
      width: 190px;
      height: 36px;
      display: inline-block;
      text-shadow: #FFFFFF 0px 0px 1px;
}

#left_menu a:active
{
      color: #FFFFFF;
      text-decoration: none;
      font-size: 14px;
      line-height: 36px;
      background-image: url(    '../images/menubox/menu_o.png' );
      background-repeat: no-repeat;
      padding: 0px 10px 0px 10px;
      margin: 0px;
      width: 190px;
      height: 36px;
      display: inline-block;
      text-shadow: #FFFFFF 0px 0px 1px;
}


my problem is how do i set the active class in c# when the page loads?

here my a tag

 <a runat="server" id="OurWorkCulture" href="~/work-culture.aspx" title="Our Work Culture">Our Work Culture</a>


when the page loads the OurWorkCulture tag must be active.

Thanks
Comment
Watch Question

Commented:
a quick soln will be


#left_menu a:active, .ActiveMenu
{
      color: #FFFFFF;
      text-decoration: none;
      font-size: 14px;
      line-height: 36px;
      background-image: url(    '../images/menubox/menu_o.png' );
      background-repeat: no-repeat;
      padding: 0px 10px 0px 10px;
      margin: 0px;
      width: 190px;
      height: 36px;
      display: inline-block;
      text-shadow: #FFFFFF 0px 0px 1px;
}

Open in new window


then

 <a runat="server" class="ActiveMenu"  id="OurWorkCulture" href="~/work-culture.aspx" title="Our Work Culture">Our Work Culture</a>

Open in new window


then when u move to another page, u can set as

ourWorkCulture.Attributes['class'] = '';

Author

Commented:
not working

Commented:
can i see ur HTML Markup?

Author

Commented:
<a class="ActiveMenu" runat="server" id="OurWorkCulture" href="~/work-culture.aspx" title="Our Work Culture">Our Work Culture</a>

#left_menu
{
}

#left_menu a
{
      color: #FFFFFF;
      text-decoration: none;
      font-size: 14px;
      line-height: 36px;
      background-image: url(         '../images/menubox/menu.png' );
      background-repeat: no-repeat;
      padding: 0px 10px 0px 10px;
      margin: 0px;
      width: 190px;
      height: 36px;
      display: inline-block;
      text-shadow: #FFFFFF 0px 0px 1px;
}

#left_menu a:hover
{
      color: #FFFFFF;
      text-decoration: none;
      font-size: 14px;
      line-height: 36px;
      background-image: url(    '../images/menubox/menu_o.png' );
      background-repeat: no-repeat;
      padding: 0px 10px 0px 10px;
      margin: 0px;
      width: 190px;
      height: 36px;
      display: inline-block;
      text-shadow: #FFFFFF 0px 0px 1px;
}

#left_menu a:active, .ActiveMenu
{
      color: #FFFFFF;
      text-decoration: none;
      font-size: 14px;
      line-height: 36px;
      background-image: url(     '../images/menubox/menu_o.png' );
      background-repeat: no-repeat;
      padding: 0px 10px 0px 10px;
      margin: 0px;
      width: 190px;
      height: 36px;
      display: inline-block;
      text-shadow: #FFFFFF 0px 0px 1px;
}

Commented:
have u checked this in Firebug? ..i checked the same in a test page. it works fine..

Author

Commented:
what is firebug?

Commented:
Firebug is an addon for Firefox browser. (which is equivalent to IE's Development Tools  - Press F12 in IE, you can see that).  using Firebug, You can edit, debug, and monitor CSS, HTML, and JavaScript live in any web page...

https://addons.mozilla.org/en-US/firefox/addon/firebug/   - install Firebug from here.

Restart ur browser, reload ur page, then right click on the "Our Work Culture" link. choose inspect element.. you will see what  CSS is applied to that link..