Copied to clipboard

Flag this post as spam?

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


  • Giuseppe 34 posts 56 karma points
    Nov 22, 2011 @ 10:11
    Giuseppe
    1

    Use parameters of macro with usercontrol

    Hi All,

    I need to pass macro's parameters to usercontrol. I have created an usercontrol and import it as macro. In umbraco backoffice, I have created a parameter as string.

    In which way I can read this parameter in my usercontrol?

    Thanks

  • Rodion Novoselov 694 posts 859 karma points
    Nov 22, 2011 @ 10:25
    Rodion Novoselov
    1

    Hi. Your macro parameter simply maps to a public property of your user control. It's a bit more convenient to start from adding a property to the control since umbraco has a feature of determining such properties and offers to add corresponding macro parameters automatically.

  • Giuseppe 34 posts 56 karma points
    Nov 22, 2011 @ 11:49
    Giuseppe
    0

    Thanks Rodion, now it's clear!

    If I want do the same with razor scripts, in which way I can declare properties into razor code?

  • Rodion Novoselov 694 posts 859 karma points
    Nov 22, 2011 @ 11:56
    Rodion Novoselov
    1

    No, you don't have to do anything special for razor scripts since all parameters declared in a macro are automatically available through the Parameter property of the DynamicNodeContext class which a macro script itself inherits (the Parameter property returns a dynamic object, so you need to call its properties by name like "Parameter.YourParameterName").

  • Giuseppe 34 posts 56 karma points
    Nov 22, 2011 @ 12:04
    Giuseppe
    0

    Thanks a lot for the support! Have a nice day

  • Swathi 7 posts 27 karma points
    Mar 28, 2014 @ 09:19
    Swathi
    0

    hi , I have added a .net user control in umbraco when i trying read that macro in RTE in content page , it show those values in content Editor after publishing it is not showing on site. can please suggest it.

    thanks in advance

  • Ghufran Ahmad 17 posts 73 karma points
    Apr 23, 2015 @ 14:39
    Ghufran Ahmad
    0

    Thanks Rodion !!

    I was stuck whole day to getting parameters inside user controls

Please Sign in or register to post replies

Write your reply to:

Draft