Get block type data


Hi all,

I have a block with name market.

i have another block ads, in that block i want to display market block data.

so how can i achive this using c# backend code not browser.

#174285 Edited, Jan 24, 2017 6:07
  • Member since: 2011

    Hi Sandeep,

    From what I could understand in Second block you want to show MarketBlock? If that is a case in Second block you need "ContentArea" as below:

    public virtual ContentArea Market {get;set;}

    And admin can drag and drop an instance of the Market block into that Second block content area you created. Other, way is to have Market block property as below:

    public virtual Market Market {get;set;}

    That means per each Second block  instance you will have an instance of  Marke means you can't re-use.


    #174286 Jan 24, 2017 7:03

    i want c# code for how to get block data

    #174291 Jan 24, 2017 7:30
  • Member since: 2011

    if(currentBlock.BlockContentArea != null && currentBlock.BlockContentArea.Items.Any())


                     foreach (var contentItem in currentBlock.BlockContentArea.Items)

    var contentLoader =   ServiceLocator.Current.GetInstance<IContentLoader>();
     var contentOfBlock = contentLoader.Get<IContentData>(contentItem.ContentLink) 



    #174296 Jan 24, 2017 9:08

    hi here what is BlockContentArea, and how to declare it. could u provide sample code snippet,

    how can i get perticular block type data( my requirement is market).

    thnaks in advance

    #174342 Edited, Jan 24, 2017 17:25
  • Member since: 2011

    can you please give me your properties and what is a requirement?

    #174350 Jan 25, 2017 7:10