i am using code render blocks in asp.net (visual studio 2010).
here is the code:
this class gets Products name ,id,price,image
public class Products
{
public string id { get; set; }
public string name { get; set; }
public string price { get; set; }
public string img { get; set; }
public Products(string id, string name, string price, string img)
{
this.id = id;
this.name = name;
this.price = price;
this.img = img;
}
}
this is the view code of aspx.webpage where class Product object is passed in the list
public partial class _Default : System.Web.UI.Page
{
public List products_list = new List();
protected void Page_Load(object sender, EventArgs e)
{
}
}
here is the source of webpage where i used this code block
<%foreach (var product in products_list)
{ %>
<%} %>
the problem is on the img tag in source i have given <%=product.img%>
here product.name and product.price is getting shown as a class Product object correctly
although in image source <%= (here) product.img%> not showing as Product object...
Replies
Know the answer? Post it — somebody with the same question will find it here.