Copied to clipboard

Flag this post as spam?

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


  • Nonacc 63 posts 184 karma points
    Mar 28, 2012 @ 18:46
    Nonacc
    0

    How can implement .net user control with parameters into cshtml ?

    How i can load macro / .net user control with parameters from cshtml ? 

    Render func, only put html on the page but serverside not working..

    Help..

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Mar 28, 2012 @ 21:39
    Jan Skovgaard
    0

    Hi Nonacc

    What version of Umbraco are you using? In Umbraco 5 you would need to inherit from the PartialView class, which means you need to have the following in the top of your view: @inherits PartialViewMacroPage

    Then you can fetch the parameters using this

    var param = model.MacroParameters.paramalias

    Then you can call the param variable where you need it in your view.

    Please note that the model referenced above is the model of the macro, not Umbraco itself.

    Hope this helps.

    /Jan

  • Nonacc 63 posts 184 karma points
    Mar 29, 2012 @ 10:14
    Nonacc
    0

    Hey Jan,

    I'm using umbraco v 4.7.0 (Assembly version: 1.0.4090.21631).

    Can you show me example of your explanation?

    I got website with one search engine macro and two languages, each time i change the language i need to pass different int parameter (pageId).

  • Michael Latouche 504 posts 819 karma points MVP 4x c-trib
    Mar 29, 2012 @ 10:57
    Michael Latouche
    0

    Hi Nonacc,

    What you would typically have is the following: in your template, you have a call to your macro, so something like this, where you declare your parameters as attributes of the macro:

    <umbraco:Macro ID="MyMacro" MyParam="SomeParam" />

     

    Then, in your macro, you would have something like this:

    @using umbraco.MacroEngines
    @inherits umbraco.MacroEngines.DynamicNodeContext

    @{
        var param = Parameter.MyParam;
        ....
    }

    Hope this helps

    Cheers,

    Michael.

Please Sign in or register to post replies

Write your reply to:

Draft