Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Arnt Grøstad 29 posts 49 karma points
    Oct 19, 2009 @ 13:52
    Arnt Grøstad
    0

    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?

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Oct 19, 2009 @ 14:08
    Dirk De Grave
    0

    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

    public string Alias {get;set;}

    and the value for the macro parameter will be passed to the user control at runtime.

     

    Cheers,

    /Dirk

     

  • Thomas Höhler 1237 posts 1709 karma points MVP
    Oct 19, 2009 @ 14:12
    Thomas Höhler
    1

    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

  • Arnt Grøstad 29 posts 49 karma points
    Oct 19, 2009 @ 14:15
    Arnt Grøstad
    0

    It was the solution from Dirk I was after.
    Nice nice :)

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Oct 19, 2009 @ 14:41
    Dirk De Grave
    0

    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

Please Sign in or register to post replies

Write your reply to:

Draft