Sitecore 5.0 API

State.MasterItem Property

Gets or sets the current master item.

[Visual Basic]
Public Shared Property MasterItem As Item
[C#]
public static Sitecore.Data.Items.Item MasterItem {get; set;}

Property Value

The current Item object.

Remarks

The current master item is used in the Sitecore client. It points to the current loaded item in the content area and is set when the content area page loads.

The scope of the value is page and it is stored the Items variable "SC_CURRENT_MASTER_ITEM".

Example

The following example processes the children of the current master item.

public void IterateChildren() {
  if (State.MasterItem != null) {
    SortedList list = State.MasterItem.GetChildrenSorted();
    for(int n = 0; n < list.count; n++) {
      IMasterItem2 child = list.GetByIndex(n) as IMasterItem2;
      ProcessChild(child);
    }
  }
}

See Also

State Class | Sitecore.Configuration Namespace