So,i have this little project im working on. Things are in Norwegain, so ill try to explain a bit.
Im making a website where i can read and add movie reviews. I have one aspx site called 'Movie reviews'which display's both Title, Review and rating (from 0-5 in a dropdownlist), and another aspx site called 'Add new movie reviews' where i can CRUD title, review and rating(dropdownlist) with the moviereviews.xml file.
Movie = film
Review = anmeldelse
Title = tittel
<movies>
<movie>
<id>1</id>
<title>Iron Man</title>
<review>Bla bla bla...</review>
<rating>2</rating>
</movie>
</movies>
a snippet of the working code behind in the 'Add new movie reviews' site:
protected void lagreBtn_Click(object sender, EventArgs e)
{
String filePath = Server.MapPath("/xml/filmanmeldelser.xml");
XElement anmeldelserXML = XElement.Load(filePath);
anmeldelserXML.Add(
new XElement("film",
new XElement("id",hentNyUnikId()),
new XElement("tittel", tittelTxt.Text),
new XElement("anmeldelse", anmeldelseTxt.Text),
new XElement("rating", rangeringDropDownList.SelectedValue)
)
);
anmeldelserXML.Save(filePath);
and another snippet of code behind in the 'Movie reviews' site:
protected string hentFilePath(string filnavn)
{
String filePath = Server.MapPath("../xml/" + filnavn);//OR ("/xml/" + filnavn)
return Server.MapPath("../xml/" + filnavn);//OR ("/xml/" + filnavn)
}
protected void visFilmanmeldelseListe()
{
String filePath = Server.MapPath("/xml/filmanmeldelser.xml");
XElement anmeldelserXML = XElement.Load(filePath);
var filmeanmeldelseListe = from filmer in anmeldelserXML.Descendants("film")
select filmer;
if(filmeanmeldelseListe.Count() > 0)
{
StringBuilder filmanmeldelseListeSB = new StringBuilder();
foreach (var film in filmeanmeldelseListe)
{
filmanmeldelseListeSB.AppendFormat(
"<article><h1>{0}</h1><p>Anmeldelse: {1}</p><p>Rangering: {2}</p></article>",
(string)film.Element("tittel"),
(string)film.Element("anmeldelse"),
(string)film.Element("rating")
);
}
filmanmeldelseListeLiteral.Text = filmanmeldelseListeSB.ToString();
}
Now, this works great...
But, (Wooah! A wild problem appeared!). Instead of numbers, showing Iron Man with a rating of 5 from the dropdownlist, i would instead like to show a star-image X times compared to the dropdownlist value chosen, like a "normal" rating control when you rate movies n such. I have this image in a file called 'pictures' within the website project.
Example: Giving a rating of 5, will show 5 stars. Gving a rating of 2, shows 2 stars.
Ive been trying for a couple of days now, and i cant seem to get my head around it... Does anyone have any good tips, tricks or solutions to get me unstuck on this problem?:)
Any help would be absolutely great!