JohnMalkowich
JohnMalkowich

Reputation: 298

Getting parameter from macro in umbraco 6 via razor

Im having trouble doing this. what i have is this macro:

<umbraco:Macro Alias="testingparameter" 
MyOwnParameter="hello" runat="server"></umbraco:Macro>

So what im trying to do is to get the hello string via my razor script: I have tried these things:

<div>test1: @Parameter.MyOwnParameter</div>
<div>test2: @(Html.Raw(Parameter.MyOwnParameter))</div>
<div>test3: @Model.Parameters.MyOwnParameter</div>

But it all returns empty string. what i get back is this

 <div>test1:</div>
 <div>test2:</div>
 <div>test3:</div>

so I guess none of the above is right, or am I just missing something?

Please note that im using umbraco 6.

Upvotes: 2

Views: 3501

Answers (1)

Digbyswift
Digbyswift

Reputation: 10400

You have to set the parameter in the macro within the backoffice too, with an alias of "myOwnParameter". See here for the documentation:

http://our.umbraco.org/documentation/reference/Templating/Macros/Razor/using-macro-parameters

Also, I recommend using camel case wherever you reference the alias, as I seem to remember that when accessing the parameter through the dynamic @Parameter collection, this is how the alias is defined.

Upvotes: 3

Related Questions