Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi all,

HTML
<ul id="menu">
  <li id="inboxList" style="text-align:right"><a href="#">Inbox(<%=inboxCount%>)</a></li>
  <li id="outboxList" style="text-align:right"><a href="#">Outbox(<%=outboxCount%>)</a></li>
  <li id="closeList" style="text-align:right"><a href="#">Closed (<%=closeCount%>)</a></li></ul>


I have an unordered list in my aspx page.
Inbox (0)
Outbox (0)
Closed (0)

and in the code behind of C# i have initialized 3 variables.
C#
public int inboxCount = 0;
public int outboxCount = 0;
public int closeCount = 0;


somehow I am changing the values of these integers dynamically. Issue is that when the value of any integer is greater than '0' than the text should change its CSS to bold as I tried it in Classic Asp style but it didn't work.

HTML
<%if (inboxCount > 0)
      { %>
    <style>
  #inboxList
  {
  	font-weight:bold;
  	color:Black;
  }
  </style>
</head>
<br />
<%}  
%>

Similarly i will apply other 2 conditions like this. But dont know how it will work perfectly..

need to display the text as following:

Inbox (1)
Outbox (0)
Closed (0)


Please help..

Thanks,

AR :)
Posted

1 solution

you can try and use style attribute from the code behind in C#.
please check below code


C#
if(inboxcount >0)
{
inboxList.Style.Add("color","Black");
inboxList.Style.Add("Font-weight","Bold");
}


similar way you can apply any style to other Li based on your condition.
 
Share this answer
 
Comments
AR547 8-Jan-14 1:55am    
Brother I cannot use runnat server in my aspx page and similarly cannot call the name of div in code behind.
But same like your answer... can we implement that condition in Javascript? I mean if I can get the value of inboxcount in Var in JS and then apply css to that ID..
Do you know how to do it in JS or any other solution in ASP?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900