Posted on 30/09/2015 16:26:35
Hi Alec
You can do that in various ways.
The template class actually have a hidden method that can be used to pass objects to the rendering engine:
Tempalte.SetTemplateValue("MyModelName", eCommerce.Products.Product.GetProductByID("Prod1"))
When you do that, you can access the object from your Razor template using GetValue:
(eCommerce.Products.Product.GetProductByID)product = GetValue("MyModelName");
If your template is a HTML version, that tag would return the value of the objects ToString()
You can also use the PageView - it has something that is more or less the same as the ViewBag/ViewData:
In your code do something like this:
PageView.Current.set_Value("MyModelName", eCommerce.Products.Product.GetProductByID("Prod1"));
When you do that, you can access the object from your Razor template using get_Value:
(eCommerce.Products.Product.GetProductByID)product = PageView.Current.get_Value("MyModelName");