Get the Alias/Property for a .net controller added from edtior
Hi. Im gonna add some .NET 2.0 Ucercontrols to a Umbraco 4.0 site. This ucercontrols are to run as macros a can be used in editor. One macro have a parameter with alias, name and type.
Ok. Im haveing a hard time figuring out how to get the value from this parameter/alias when coding in the ucercontrollers code-bind. Any tip for how getting the parameter value?
Public properties are the key here. Macro's pass parameters onto user controls based on the macro parameter alias name. For example, if you have a macro with a single parameter for which alias = 'Alias', then just declare a public property in your class
public string Alias {get;set;}
and the value for the macro parameter will be passed to the user control at runtime.
If you are using .Net Usercontrols just add public properties to the usercontrol. After deploy to umbraco (compiling, uploading ascx and dll) just go to the macro and select "Browse usercontrols on server", select the ascx hit save and then hit "Browse properties".
So now are the properties available in the parameters tab. The values of these parameters will be filled automatically by umbraco to the public properties in the usercontrol.
Great follow up by thomas, his method will remove the chance of using wrong parameter alias names for properties declared in your custom control (and might be the preferred way of using this)
Get the Alias/Property for a .net controller added from edtior
Hi. Im gonna add some .NET 2.0 Ucercontrols to a Umbraco 4.0 site.
This ucercontrols are to run as macros a can be used in editor. One macro have a parameter with alias, name and type.
Ok. Im haveing a hard time figuring out how to get the value from this parameter/alias when coding in the ucercontrollers code-bind.
Any tip for how getting the parameter value?
Arnt,
Public properties are the key here. Macro's pass parameters onto user controls based on the macro parameter alias name. For example, if you have a macro with a single parameter for which alias = 'Alias', then just declare a public property in your class
and the value for the macro parameter will be passed to the user control at runtime.
Cheers,
/Dirk
Hope that I understand you right:
If you are using .Net Usercontrols just add public properties to the usercontrol. After deploy to umbraco (compiling, uploading ascx and dll) just go to the macro and select "Browse usercontrols on server", select the ascx hit save and then hit "Browse properties".
So now are the properties available in the parameters tab. The values of these parameters will be filled automatically by umbraco to the public properties in the usercontrol.
Is this what you searched for?
Thomas
It was the solution from Dirk I was after.
Nice nice :)
Great follow up by thomas, his method will remove the chance of using wrong parameter alias names for properties declared in your custom control (and might be the preferred way of using this)
+1 for thomas!
Cheers,
/Dirk
is working on a reply...