c# - Condition a <div> to appear in ASP.NET from a List -
i have list total of categories, want ones "featured" appear. code:
<div class="categories"> <% (int = 0; < lista.count; i++){ %> <% var categorias = lista[i]; %> <div id="cats"><a id="categoriabtn" href="#" title="button"><%= categorias.name %></a></div> <%} %> </div>
this generates list shows of categories names, implementing "featured categories" option, want skip ones have boolean alternative false:
categorias.featured == false
i tried this:
<div class="categories"> <% (int = 0; < lista.count; i++){ %> <% var categorias = lista[i]; %> <% if (categorias.featured == true){ %> <div id="cats"><a id="categoriabtn" href="#" title="button"><%= categorias.name%></a></div> <br /> <%} else{ this.visible = false; } } %> </div>
while writing create work, think there wrong in it. want create sure there no problems before publishing change.
this code has fundamental problem. giving multiple html elements same id. each 1 should unique. i'd this:
<div class="categories"> <% (int = 0; < lista.count; i++){ %> <% var categorias = lista[i]; %> <% if (categorias.featured == true){ %> <div id="cats<%=i%>"><a id="categoriabtn<%=i%>" href="#" title="button"><%= categorias.name%></a></div> <br /> <%} } %> </div>
c# html asp.net
No comments:
Post a Comment