I have a partial view that is not rendering:
The designer is telling me
the foreach(Dress d in Model) is missing a closing character “}”
the foreach(Picture p in d.Pictures) is missing a closing character “}”
and the LI item is not closed
@model IEnumerable<MyApp.Model.Dress>
<ul class="thumbs noscript">
@{
foreach (Dress d in Model)
{
foreach(Picture p in d.Pictures)
{
string dressPrefix = "images/Dresses/"+p.Dress.DressName;
string bigThumb = dressPrefix+"-"+p.Caption+"_bigthumb.jpg";
string thumb = dressPrefix+"-"+p.Caption+"_thumb.jpg";
string dressTitle = d.DressName+" "+d.Price.ToString();
<li>
<a class="thumb" href="@bigThumb" title="@dressTitle">
<img src="@thumb" alt=""@dressTitle" />
</a>
</li>
}
}
}
</ul>
public class Dress
{
public int ID { get; set; }
public int GalleryTypeID { get; set; }
public virtual GalleryType GalleryType { get; set; }
public int DressTypeID { get; set; }
public virtual DressType DressType { get; set; }
public int DesignerID { get; set; }
public virtual Designer Designer { get; set; }
public string Description { get; set; }
public string DressName { get; set; }
public string Bust { get; set; }
public int DressLength { get; set; }
public int SleeveLength { get; set; }
public decimal Price { get; set; }
public int Waist { get; set; }
public int test { get; set; }
public virtual ICollection<DressColor> DressColors { get; set; }
public virtual ICollection<Picture> Pictures { get; set; }
}
public class Picture
{
public int ID { get; set; }
public Dress Dress { get; set; }
public string Caption { get; set; }
public string PictureURL { get; set; }
}
Any ideas?
Take out hte extra braces, also you have an extra quote in the alt attribute of the img tag, which is probably what is causing your unclosed tag problem.
FYI, you really shouldn’t be doing that much code in your view, that should be in your controller. You should also use string.Format to format the strings, not using the
+operator.