We're having problems accessing the built in Category property in a block. If we get a default instance of a block and quickwatch it when debugging, we can see that the Category property is there, reached by ((Castle.Proxies.MyBlockProxy) (CurrentBlock)).Category. But how can we reach the categorylist by our CurrentBlock and be able to use its values? Or isn't this built in category property supposed to be used in a block?
you need cast it to
And how easy it is when you know the answer. Thanks a lot :)
For those who are still confused, this is how I finally got it to work:
which returns a CategoryList object.
How do you set category programmatically cuz ((EPiServer.Core.ICategorizable)CurrentBlock).Category is just a get not set.
You can set the Category by casting your block as an ICategorizable object, and then adding the category ID.((EPiServer.Core.ICategorizable)<block>).Category.Add(<category id>);