It seems strange if you get a NULL when you cast your CurrentData to IContent.
The instance of the Block is in runtime created as a Proxy Class with IContent as a "mixin". Hence there are no programmatically relations with your BlockData and the IContent.
Note that this only works when you use your Block as a Shared Block, not if you add the Block as a Local Block (a Property on a Page).
I think that is the issue - I am using the block as a property on another block.
So as an example, I have a block called NewsList of which one of the properties is SectionBlockTitle.
From the Template of SectionBlockTitle, can I access the name of the parent NewsListBlock?
Maybe not otpimal but you could maye load in block instance.
var repository = EPiServer.ServiceLocation.ServiceLocator.Current.GetInstance<IContentRepository>();
IContent block = repository.Get<IContent>(content.ContentLink);
Per, what should "content" on your second row be?
In this case, the SectionTitleBlock is a local Block inside a Shared Block.
None the less, CurrentData on SectionTitleBlock cast to IContent will return null since it is a Local Block.
I have created a block called SectionTitleBlock with the following model and view:
I want the Title property in the view to return the name of the block when the title has not been filled out by the user on the block.
I am trying to cast this.CurrentData to IContent to retrieve the name, however the cast results in null - looking at the inheritance of the classes and interfaces this looks correct not to cast correctly.
I can cast this.CurrentData to IContentData but that still does not provide me the name of the block as it was created in CMS.
Can anyone help?