In one of my SurfaceController methods, I new up my CustomModel by its default ctor, which results in an invocation of the UmbracoHelper to find the current PageId. And here is the issue - this value is null, and the model creation fails.
I've tried also to pass on the CurrentPage of the SurfaceController instance to the ctor of my model, but this also fails. The SurfaceController method is a GET operation triggered from an @Html.ActionLink in a view of my controller. Btw. when I hit my first operation of my controller (triggered by an @Html.Action in my umbraco template, the CurrentPage value is fine and set, but not on the subsequent methods.
I use umbraco version 6.0.5.
PS: The problem wouldn't exist if I could use a model which did not have to inherit from RenderModel, but I guess this is needed when specifying the Layout of the views (or am I wrong?)
Hi, i have not been able to do this esp a problem in partial views and AJAX postaback. I ended up creating a property in my model to hold the NodeId then setting this in the view then when i post i submit the nodeid in a hidden field, so i have it on post back :). Hope that helps.
Good idea to supply the model as a parameter to the call.
I actually ended up doing a post request instead (by using an UmbracoForm). This way, the Umbraco context isn't lost. I had a problem if from my sufrace controller's HttpGet-method would return a view which needed the Umbraco context (ie. to do a RenderMacro, or to get and Umbraco Field element).
Still, I would like to be able to use the ActionLinks and still have my Umbraco context, but I guess I'm in the same boat as the Ajax users waiting for Umbraco to have a general solution for the loss of the Umbraco context.
There is something coming up for it. I dont like the umbraco helper implimetation. I prefer using the http and ajax request and just passing the value in my model. Then i have control of what is going on. Its just me i guess, i like to know what is going on with out relying on something else or someone elses implimentation. I I dont see any bad having it as a property in a model and have actually found loads of uses it for it esp when trying to impliment some sort of custom email functions :)
I agree. But the loss of context (ie. with the ActionLink) will stop the flow of having the surface controller to return a view which includes helpers which rely on the umbraco context.
Getting CurrentPage from SurfaceController
Hi
I have a SurfaceController with a couple of methods to handle a corresponding model I have. As I need to set the Layout inheritance of the views of my SurfaceController, I have my model subclassing the umbraco RenderModel, as described here: our.umbraco.org/.../40252-Umb-6-Custom-Model-The-model-item-passed-into-the-dictionary-is-of-type-requires-UmbracoWebModelsRenderModel.
My model looks like in the article link:
In one of my SurfaceController methods, I new up my CustomModel by its default ctor, which results in an invocation of the UmbracoHelper to find the current PageId. And here is the issue - this value is null, and the model creation fails.
I've tried also to pass on the CurrentPage of the SurfaceController instance to the ctor of my model, but this also fails. The SurfaceController method is a GET operation triggered from an @Html.ActionLink in a view of my controller. Btw. when I hit my first operation of my controller (triggered by an @Html.Action in my umbraco template, the CurrentPage value is fine and set, but not on the subsequent methods.
I use umbraco version 6.0.5.
PS: The problem wouldn't exist if I could use a model which did not have to inherit from RenderModel, but I guess this is needed when specifying the Layout of the views (or am I wrong?)
Hi, i have not been able to do this esp a problem in partial views and AJAX postaback. I ended up creating a property in my model to hold the NodeId then setting this in the view then when i post i submit the nodeid in a hidden field, so i have it on post back :). Hope that helps.
Thanks for your reply.
My surfacecontroller is triggered by an ActionLink which makes a GET-request:
@Html.ActionLink("[Some label text]", "[My Controller Operation]", "[My Surface Controller]", new { [My Parameters List })
So I don't get the my model transferred. For that to happen, I guess I will need an umbraco form and a POST-request?..
You could just pass it in the IDictornary (Its a parameter on the ActionLink) then you could get the id in your controller?
Good idea to supply the model as a parameter to the call.
I actually ended up doing a post request instead (by using an UmbracoForm). This way, the Umbraco context isn't lost. I had a problem if from my sufrace controller's HttpGet-method would return a view which needed the Umbraco context (ie. to do a RenderMacro, or to get and Umbraco Field element).
Still, I would like to be able to use the ActionLinks and still have my Umbraco context, but I guess I'm in the same boat as the Ajax users waiting for Umbraco to have a general solution for the loss of the Umbraco context.
There is something coming up for it. I dont like the umbraco helper implimetation. I prefer using the http and ajax request and just passing the value in my model. Then i have control of what is going on. Its just me i guess, i like to know what is going on with out relying on something else or someone elses implimentation. I I dont see any bad having it as a property in a model and have actually found loads of uses it for it esp when trying to impliment some sort of custom email functions :)
I agree. But the loss of context (ie. with the ActionLink) will stop the flow of having the surface controller to return a view which includes helpers which rely on the umbraco context.
What context are you trying yo use in your actionlink?
is working on a reply...