Forums - C# Corner

Forum guidelines
arsalan jibran

arsalan jibran

  • 1.5k
  • 6
  • 603

asp inline tags / code render blocks

Mar 13 2018 10:18 AM
i am using code render blocks in (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)
{ = id; = 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> products_list = new List<Products>();
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)
{ %>
<div class="col-md-3 col-md2">
<div class="col-md1 simpleCart_shelfItem">
<a href="web/single.html">
<img class="img-responsive" src="<%=product.img%>" alt=""/>
<h3><a href="web/single.html">< %></a></h3>
<div class="price">
<h5 class="item_price"><%=product.price %></h5>
<a href="#" class="item_add">Add To Cart</a>
<div class="clearfix"> </div>
<%} %>
the problem is on the img tag in source i have given <%=product.img%>
here and product.price is getting shown as a class Product object correctly
although in image source <%= (here) product.img%> not showing as Product object...

Attachment: WebApplication1.rar