Try our conversational search powered by Generative AI!

Can I get the displayname of a block programmatacally

Vote:
 

How can I get the displayname of a block in code?

#85619
Apr 30, 2014 14:46
Vote:
 

Hi, yes by casting the block to IContent

var content = myBlock as IContent;

if (content != null)
{
    var name = content.Name;
}

    

#85639
Apr 30, 2014 22:41
Vote:
 

Or do you mean the type's displayname?

var repo = ServiceLocator.Current.GetInstance<BlockTypeRepository>();
var blockType = repo.Load<T>();
return blockType.DisplayName;

    

#85988
May 09, 2014 16:09
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.