Hmm I'm not really used to dynamic code (I prefer Model.Content which is strongly typed), but I think it should work. The only thing I can find is that you have an @ before CurrentPage which is not allowed.
It might be because it's a partial view. So just like you pass the node id in the ViewDataDictionary you could try the same for Model.Content or CurrentPage.
The Model get's set in a Controller and when you're using a partial view it won't reach that controller so perhaps that's why it doesn't work. Glad you got it fixed like this. Please mark a post as the solution if it helped you.
Partial CurrentPage is null
I am reusing some code i've used a lot before in a current project and getting a null exception for CurrentPage
The only difference in the project this is happening in is that I am using the Optimus package.
Any ideas where to start troubleshooting please?
Called with
Hmm I'm not really used to dynamic code (I prefer Model.Content which is strongly typed), but I think it should work. The only thing I can find is that you have an @ before CurrentPage which is not allowed.
Jeroen
Oops, yes left @ in when trying to troubleshoot. I get Object reference not set to an instance of an object when using Model.Content.
It's very odd, this works perfectly in the website I branched this solution from.
It might be because it's a partial view. So just like you pass the node id in the ViewDataDictionary you could try the same for Model.Content or CurrentPage.
Jeroen
I'll give that a go, thanks. As a note, if i dont send a ViewDataDictionary at all, it works fine (obviously setting an int for the root Id).
"So just like you pass the node id in the ViewDataDictionary you could try the same for Model.Content or CurrentPage."
That worked, thank-you. Does ViewDataDictionary take over the Model for a partial then?
The Model get's set in a Controller and when you're using a partial view it won't reach that controller so perhaps that's why it doesn't work. Glad you got it fixed like this. Please mark a post as the solution if it helped you.
Jeroen
is working on a reply...