Sitecore 5.0 API

State.CustomLayout Property

Gets or sets the ID or name of a custom layout to use for the current page request.

[Visual Basic]
Public Shared Property CustomLayout As String
[C#]
public static string CustomLayout {get; set;}

Property Value

The ID or name of the custom layout.

Remarks

The default layout can be overridden by setting the custom layout before the web engine starts (typically in Page_Init or a page handler). This can be used to build the layout programatically in conjunction with AddRenderings and RemoveRenderings.

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

Example

The following example builds a special layout if the user is a special user.

  public void BuildVIPLayout(string user) {
    if (user == "VIP") {
      State.CustomLayout = "VIP layout";
      State.AddRenderings.Add("VIPRendering");
    }
    
    void Page_Init() {
      BuildVIPLayout(myUser);
    }
  }

See Also

State Class | Sitecore.Configuration Namespace