I got some help here last night about getting the collection index. Here is the code I'm using.
System.Text.StringBuilder sb = new System.Text.StringBuilder();
for (int i = 1; i < _prod.ActiveProductItemCollection.Count; i++)
{
sb.Append("<script type='text/javascript'>");
sb.Append("mboxCreate(\"product_productpage_rec{0}\")", i);
sb.Append("\"entity.id=" + _prodID + "\",");
sb.Append("\"entity.categoryId=" + _categoryID + "\",");
sb.Append("\"entity.name=" + _prod.ActiveProductItemCollection[i].Title + "\",");
sb.Append("\"entity.pageURL=" + Request.Url.ToString() + "\",");
string filename = AppSettingsManager.Current.ProductImagePathLarge + _prod.ActiveProductItemCollection[i].Sku
+ AppSettingsManager.Current.ProductImageExtension;
sb.Append("\"entity.thumbnailURL=" + filename + "\",");
sb.Append("\"entity.inventory=" + _prod.ActiveProductItemCollection.Count + "\",");
sb.Append("\"entity.value=" + _prod.ActiveProductItemCollection[i].ActualPrice + "\",");
sb.Append("\"entity.ProductItemID=" + _prod.ActiveProductItemCollection[i].Sku + "\",");
sb.Append("\"entity.addToCartImg=~/Images/Buttons/btn_AddToCartFlat.gif\");<");
sb.Append("/script>");
}
this.LiteralMBoxScript.Text = sb.ToString();
What I want to do is get the index of the item in the collection after productpage_rec.
So, for example, the first product will generate, for example,
mboxCreate ("product_productpage_rec1"
etc. etc. for each product in the collection. When I try to build, I get the following error:
"cannot convert from string to char"
Will work on product_productpage_rec {0}
What am I missing?
Thanks in advance.
tking source
share