Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I'm working on my first Umbraco 7 project and decided to use a SurfaceController for a simple form which I wanted to wrap in a macro.
This went pretty smooth until well, requirements changed and I needed to expand the form to also handle edits.
I decided to stick with the SurfaceController because I wasn't sure if the custom routing/hijacking would still allow my form to be contained within a macro, but it turned out I really can't setup routing for a SurfaceController.
Eventually I managed with some workarounds (using querystring and urlrewriting) but now I'm wondering which approach I should have taken in the first place. Should I have ditched the SurfaceController and moved to custom routing? How would I wire it up in a macro? Or is there anything else I'm missing?
Looking forward to hear your experiences :)
When you need a SurfaceController for a macro the general approach is to have a SurfaceContoller which returns a Partial View, then have a Partial View Macro which only contains @Html.Action. You can of course pass macro parameters to your controller through the partial view macro.
Does that make sense?
That is the setup I'm using and it works fine with just one Index action and an HTTP POST (form submit).
What I don't fully understand is how to handle routing when I add more actions to the surface controller, in my case the Edit action with an identifier, and the HTTP POST after editing.
Is the routing perhaps to be handled by the template, which passes the identifier using a macro parameter?
How would I configure routing in that case? (e.g. /myform/edit/3)
I may be missing something obvious here, but my main concern is: are surface controllers able to deal with this MVC approach (and routing) within a macro or should I work with a custom MvcRenderController instead (which I'm not sure will work with a macro)?
So SurfaceCOntrollers are auto routed, but they can have child actions which you can either render with a @Html.Action or for a form you can use @using(Html.BeginUmbracoForm("CreateComment", "BlogPostSurface"))
MvcRenderController is route hijacking so will not work with a Macro.
Does the above help at all?
Child actions indeed seem to provide more options using querystring.
When I have a moment I'll have a look at the routing mechanism.
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted