Jump to content

Umbraco/Samples and Articles/Dot Net Controls/Using Page Properties In UserControls

From Wikibooks, open books for an open world

If you use usercontrols, wrapped in macros, in templates, this trick could save you a lot of time.

This is achieved by using squarebrackets and a "#". Remember, that in template you can also use # for dictionary item, but only when using GET_ITEM. Dictionary items will not work for Macro parameters.

Syntax: <?UMBRACO_MACRO macroAlias="myAlias" myProperty="[#propertyAlias]" />

Sample: <?UMBRACO_MACRO macroAlias="myAlias" myProperty="[#bodyText]" />

This also works with default properties like <?UMBRACO_MACRO macroAlias="myAlias" myProperty="[#pageID]" />

More:

Label="[@name]" : Request["name"]
Label="[%name]" : Session["name"]
Label="[#name]" : Page.Elements["name"]