I want to create a Sitecore sublayout like the following:
<sc:Sublayout runat="server" ID="slMySublayout" Path="~/layouts/My Sublayout.ascx" MyCustomProperty="some value" />
I was hoping that since a Sitecore sublayout is inherited from an ASP.NET user control that I would be able to create a public property called “MyCustomProperty” and get at the value that was set declaritively for the sublayout. However that doesn’t seem to work. The public property never seems to get set with the value entered on the ASCX file.
Does anyone know if this is possible?
Thanks,
Corey
I figured it out. Instead – you write your sublayout tag like this:
Then make sure that your sublayout inherits from SublayoutBase (shared source – http://trac.sitecore.net/SublayoutParameterHelper/browser/Trunk/Web/UI/Sublayouts/SublayoutBase.cs). As long as you have a public property on your sublayout called MyCustomProperty, then it will get set correctly at load. If you have multiple properties you can just set them all in the Parameters section – just use an ampersand between them.