Sub Layout Parameter Helper

  0 rating
CMS;Developers
3/22/2013 3:40:07 AM
3/22/2013 3:40:07 AM
Provider: Sitecore

About

You can use the SublayoutParameterHelper to access the data source and parameters passed to a sublayout. 



Last documented compile: Sitecore 6.0.1 090212 

Documentation

Documentation
  • Documentation > Getting Started with the Sub Layout Parameter Helper
    Getting Started with the Sub Layout Parameter Helper

    You can use the SublayoutParameterHelper to access the data source and parameters passed to a sublayout.

    You can use the SublayoutParameterHelper in one of two ways:

        * Use a Sitecore.Sharedsource.Web.UI.Sublayouts.SublayoutParameterHelper.
        * Your sublayouts can inherit from Sitecore.Sharedsource.Web.UI.Sublayouts.SublayoutBase instead of directly from System.Web.UI.UserControl.

    Sitecore.Sharedsource.Web.UI.SublayoutsSublayoutParameterHelper

    You can use a SublayoutParameterHelper from the code-behind of a sublayout as follows:

    Sitecore.Sharedsource.Web.UI.Sublayouts.SublayoutParameterHelper subHelper =
      new Sitecore.Sharedsource.Web.UI.Sublayouts.SublayoutParameterHelper(this, false);
    string parameter = subHelper.GetParameter("ParameterName");

    The first parameter to the constructor for the SublayoutParameterHelper class is the user control (the sublayout itself).

    The second parameter controls whether the helper sets properties of the user control to corresponding parameter values. If the sublayout exposes public DataSource or DataSourceItem properties, the SublayoutParameterHelper populates them with the data source for the sublayout. If the sublayout exposes a property named PropertyName and is passed a parameter named PropertyName, the SublayoutParameterHelper sets that property to the value of that parameter.

    Sitecore.Sharedsource.Web.UI.SublayoutBase

    Instead of using a SublayoutParameterHelper from the code-behind of a sublayout, your sublayout can inherit from Sitecore.Sharedsource.Web.UI.SublayoutBase. This base class provides the DataSourceItem property, which exposes the data source for the sublayout (which defaults to the context item) and the GetParameter() method that retrieves a parameter value or an empty string. This class passes true to its Sitecore.Sharedsource.Web.UI.Sublayouts.SublayoutParameterHelper, so if your class defines any properties, the base class will set them from parameters.

    Note: If your sublayout implements OnInit(), that method should first call base.OnInit(), which applies parameters to the sublayout.

    0
Back
Release notes
The module was added 04-03-2009
Read more Back
Code examples

Solution screenshots(0)

Upload

Reviews (0)

Sort by: Date Most votes
  • Profile Avatar
    [fullName]

    Level: 0

    x0 x0 x0

    [date]

    [title]

    [text]

    Was this helpful?

    0

Comments (0)

Sort by: Date  Most votes

Leave a Comment

Comment must be field in
Post comment
loader

Write a review

Title can't be empty
Review can't be empty
Post review

Download

Title Description Download Action

Add File