C# HTMLControl Style.Add

imotintopp

New Member
I have a web site created using C# and Visual Studio.I have the following menu in my Site.master:\[code\]<div class="menu"> <ul> <li runat="server" id="liHome"> <a href="http://stackoverflow.com/questions/15570083/Default.aspx">Home</a></li> <li runat="server" id="liAbout"> <a href="http://stackoverflow.com/questions/15570083/About.aspx">About</a></li> <li runat="server" id="liContact"><a href="http://stackoverflow.com/questions/15570083/ContactUs.aspx">Contact</a></li> </ul></div>\[/code\]And I have the following css:\[code\].menu ul {}.menu ul li a{padding:9px 10px; display:block; color:#fff; font-size:16px; font-weight:bold;}.menu ul li a:hover{color:#00ff00; text-decoration:none; }\[/code\]What I want to do is when the menu is clicked, I want the text of the selected menu item to change and stay a different colour. In my Site.master.cs I am doing the following for the 'About' menu item for example:\[code\] if (Request.Url.ToString().Contains("About") == true) { liContact.Style.Add("color", "#00ff00"); }\[/code\]But the colour does not stay green. Can anyoe help me as to what I'm doing wrong?Thanks
 
Back
Top