c# - ASP MVC 2 issue - trying to display images in a for-loop in a view -
i'm trying display ranking video game review. ranking displayed number of gold stars out of 5. so, if game has review score of 3, there should 3 gold stars, followed 2 gray/empty stars.
i have following loops in view render images:
<% (int = 0; < model.game.reviewscore; ++i) { %> <img src="~/content/images/review/goodscore.png" alt="" runat="server" /> <% } %> <% (int j = 0; j < (5 - model.game.reviewscore); ++j) { %> <img src="~/content/images/review/badscore.png" alt="" runat="server" /> <% } %>
the problem 1 goodscore.png
image being displayed in loop. similarly, if score allows empty stars, 1 badscore.png
displayed.
looking @ rendered html game score of 3, see:
<img src="../content/images/review/goodscore.png" /> <img /> <img /> <img src="../content/images/review/badscore.png" /> <img />
so, looks math in loops right, it's image path isn't being written 2nd+ iterations. ideas on what's causing this?
i suspect need remove runat="server"
inside img tags. tells asp handle tag. want client display image.
use helper, eg: url.content(...)
insert correct path beginning ~ in mvc.
Comments
Post a Comment