In my form partial view I'm trying to get a sibling of the current page to add some navigation in. But I cannot seem to work out how to get the current page.
so Model.Content / CurrentPage is unavailable. I could use @Umbraco.TypedContent but as I cannot work out how to get the ID of the current page I cannot use that.
In my partial view if I try and get the next sibling using this code it gives a The name 'CurrentPage' does not exist in the current context error.
var test = CurrentPage.Next();
Trying it this way gives, 'Racing.CheckoutModel' does not contain a definition for 'Content' and no extension method 'Content' accepting a first argument of type 'Racing.CheckoutModel' could be found (are you missing a using directive or an assembly reference?)
Setting my CheckoutModel to inherit from RenderModel allows me to get the sibling using Model.Content however I get this exception when posting my form.
No parameterless constructor defined for this object.
When I give CheckoutModel a parameterless constructor it moans that RenderModel doesn't have a constructor that doesn't allow it.
I don't see how to pass the currentpage to my model during the post however.
CurrentPage / Model.Content in partial view
In my form partial view I'm trying to get a sibling of the current page to add some navigation in. But I cannot seem to work out how to get the current page.
My partial inherits from a custom model
so Model.Content / CurrentPage is unavailable. I could use @Umbraco.TypedContent but as I cannot work out how to get the ID of the current page I cannot use that.
Can anyone help?
When you say you cannot get it to work? What is the problem? Charlie :)
In my partial view if I try and get the next sibling using this code it gives a The name 'CurrentPage' does not exist in the current context error.
Trying it this way gives, 'Racing.CheckoutModel' does not contain a definition for 'Content' and no extension method 'Content' accepting a first argument of type 'Racing.CheckoutModel' could be found (are you missing a using directive or an assembly reference?)
Umbraco.Web.Mvc.UmbracoViewPage
Thats because of this statement and i am not sure how to fix it.
Try using Umbraco.Web.Mvc.UmbracoViewPage
and dont use any of the model properties, just to assert this is the case. Charlie :)
You could let your custom model inherit from RenderModel (which Umbraco uses everywhere): http://our.umbraco.org/forum/templating/templates-and-document-types/38311-Using-RenderMvcController?p=2#comment153025
So you have your own model with it's own properties, but Model.Content will also work.
Jeroen
Jeroen, this sounds like a great solution. Can you just call Model...... ect ect from your own model?
If the context is null will this throw? Charlie :)
You can just do Model.YourOwnProperty, but also Model.Content.Children to get the children of the current node.
Jeroen
Setting my CheckoutModel to inherit from RenderModel allows me to get the sibling using Model.Content however I get this exception when posting my form.
No parameterless constructor defined for this object.
When I give CheckoutModel a parameterless constructor it moans that RenderModel doesn't have a constructor that doesn't allow it.
I don't see how to pass the currentpage to my model during the post however.
Try this :-) http://our.umbraco.org/forum/templating/templates-and-document-types/38311-Using-RenderMvcController?p=2#comment155535
Jeroen
Note to self, scroll through threads in case there is anything else pertinent ;)
Thanks Jeroen
Doh just marked the wong post as solution ;)
is working on a reply...