Passing macro parameters into Partial View Macro File
Hi there,
I'm using v7.2.8 and I'm trying to pass a node Id through to a macro partial that will then grab the content and pass it out as JSON.
I cannot get the nodeId to be treated as a corrent Node and I end up having to hard code the id to get any text in JSON.
What am I doing wrong.
Template
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@{
Layout = null;
}
@Umbraco.RenderMacro("flexibleJson", new {nodeId="1102"})
Partial View Macro
@inherits Umbraco.Web.Macros.PartialViewMacroPage
@using umbraco.NodeFactory
@{
var macroNodeId = Model.MacroParameters["nodeId"];
var termsAndConditionsNode = new Node(1102);
var jsonToReturn = new {
macroNodeId = macroNodeId,
headerText = termsAndConditionsNode.GetProperty("pageHeader").Value,
bodyText = termsAndConditionsNode.GetProperty("bodyText").Value
};
string json = Json.Encode(jsonToReturn);
Response.ContentType = "application/json";
}
@Html.Raw(json)
When I look at the rendered JSON the macroNodeId is coming through correctly as the specified 1102 - but there doesn't seem to be a way to get it to parse through as an actual node.
Passing macro parameters into Partial View Macro File
Hi there,
I'm using v7.2.8 and I'm trying to pass a node Id through to a macro partial that will then grab the content and pass it out as JSON.
I cannot get the nodeId to be treated as a corrent Node and I end up having to hard code the id to get any text in JSON.
What am I doing wrong.
Template
Partial View Macro
When I look at the rendered JSON the macroNodeId is coming through correctly as the specified 1102 - but there doesn't seem to be a way to get it to parse through as an actual node.
I've tried .ToString(); converting to INT - etc.
What am I missing?
Hi Ian,
Try this below
Dazza
Once again Dazza you've shown me why I should stick to the CSS - I knew it would be a simple thing.
Many thanks - another cold beer I owe you!
is working on a reply...