An unknown error occured while rendering the
following code:
System.ArgumentNullException: A node must be provided to make a dynamic
instance Parameter name: n at
umbraco.MacroEngines.DynamicNode..ctor(INode n) at CallSite.Target(Closure ,
CallSite , Object ) at
System.Dynamic.UpdateDelegates.UpdateAndExecute1[T0,TRet](CallSite site, T0
arg0) at RazorEngine.Dynamic.cebadcaaad.Execute() at
RazorEngine.Templating.TemplateService.Parse[T](String template, T model, String
name) at umbraco.MacroEngines.RazorEngine.GetResult(String cacheIdentifier,
String template, INode currentPage, String& result)
Razor syntax for Model.Parent
To my understanding "Model" object in razor syntax is equivelent to "currentPage" in xslt.
Now I want to access the Parent of the current page/node. So I tried to access like
@Model.Parent
But I am getting following error:
==================================================================
Razor Macro Engine
An unknown error occured while rendering the following code:System.ArgumentNullException: A node must be provided to make a dynamic instance
Parameter name: n
at umbraco.MacroEngines.DynamicNode..ctor(INode n)
at CallSite.Target(Closure , CallSite , Object )
at System.Dynamic.UpdateDelegates.UpdateAndExecute1[T0,TRet](CallSite site, T0 arg0)
at RazorEngine.Dynamic.cebadcaaad.Execute()
at RazorEngine.Templating.TemplateService.Parse[T](String template, T model, String name)
at umbraco.MacroEngines.RazorEngine.GetResult(String cacheIdentifier, String template, INode currentPage, String& result)
Your Razor template:
<div>
@Model.Level
<hr/>
@Model.Parent.GetType().ToString()
</div>
===================================================================
Looking for help on how to access the Parent node.
Thanks in advance.
Thanks & Regards,
Pinal Bhatt
Gotcha...
I don't know why Model.Parent does not works, but if we take this into some variable then it works fine.
This way it works and we can access "Parent" page via vaiable.
is working on a reply...