Render block name

Member since: 2007


Is there a nice way to render a block name? I've tried most combinations like:

<%= CurrentBlock["Name"] %>
<%= CurrentBlock["BlockName"] %>
<%= CurrentBlock["ContentName"] %>

The only way that seems to work is:

<%= CurrentBlock.Property[0] %>


#77037 Nov 06, 2013 23:00
  • Member since: 2009

    maybe not so nice, but you could do this:



    #77039 Nov 07, 2013 7:45
  • Member since: 2007

    Well, better than my approach. Thanks,

    Shouldn't Name be a property on BlockData?

    #77090 Nov 07, 2013 22:29
  • Member since: 2004

    The reason Name is not a property on BlockData is that Name is part of interface IContent. Blocks are a special building block which can both be used as properties on pages (often referred to as local blocks) in that case the block will not implement IContent. However blocks can also be created as own entititys (often referred to as shared blocks), in that case at runtime a subclass to the block type is created, this new subclass will implement IContent (and hence a shared block instance have a Name while a local block doesn't). More info is here

    #77101 Nov 08, 2013 11:48
  • Member since: 2007

    Thanks for the update Johan. Makes sense!

    #77115 Nov 08, 2013 18:50