Get current page in block's Set Default Values method.

Vote:
 

I need to set a block's property on the basis of a page property under which that block is being created.

So, to achieve this, I have overriden SetDefaultValues method in block type. And in this method I tried getting current page from IPageRouteHelper interface using below code.

http://www.jondjones.com/learn-episerver-cms/episerver-developers-guide/episerver-api-explained/episerver-7-how-do-i-get-the-currentpage-from-a-controller

But it always returns StartPage as the current Page.

How can we get the current Page in the bllock type?

Thanks.

#183121
Oct 05, 2017 14:25
Vote:
 

I'm not sure that is possible. A block isn't created "under" a page. It is created in a ContentFolder, and after that it can be added to a page (in e.g. a content area). When a block is created there isn't a current page.

#183151
Oct 05, 2017 20:50