Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Willem Luijk 24 posts 95 karma points
    Aug 29, 2015 @ 12:10
    Willem Luijk
    0

    How to create links in typical CRUD scenario to jump from the index page to the Detail page in same SurfaceController

    Please can someone help me out? I am new to Umbraco.

    I am moving a crud scenario from MVC 4 to Umbraco. I created a SurfaceController that returns a partial named "AnimalIndex". In the template is de code:

    @{ Html.RenderAction("Index", "Animal");}
    

    That is working fine, the final page is decorated with top and bottom templates. However now we need to wire up these buttons:

    @Html.ActionLink("Details", "Details", new { id = item.ID })
    @Html.ActionLink("Edit", "Edit", new { id = item.ID })
    @Html.ActionLink("Delete", "Delete", new { id = item.ID })
    

    I tried this one for Details:

    <a href="@Url.Content("~/For-Sale-With-Members/Details?id="+item.ID.ToString())">Details</a>
    

    ...and pointed the link to another called Details with the "For-Sale-With-Members/Details" link. This is an awfull solution. Each time the page is renamed the links are broken.

    The results of these links are pages that has bypassed by the Umbraco render engine and the link generates this error:

    Server Error in '/' Application.
    
    The "RenderBody" method has not been called for layout page "~/Views/Animal.cshtml".
    
    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 
    
    Exception Details: System.Web.HttpException: The "RenderBody" method has not been called for layout page "~/Views/Animal.cshtml".
    
  • Dave Woestenborghs 3504 posts 12134 karma points MVP 9x admin c-trib
    Sep 05, 2015 @ 08:46
    Dave Woestenborghs
    0

    Hi Willem,

    You can do this behavior entirely client side with angular.

    Tim Geyssens wrote a blog about this : http://www.nibble.be/?p=224 This is Umbraco 6 but the same idea applies to Umbraco 7. Mind that you can run in to browser support with this if you need to support older browsers.

    Another option is to use Virtual nodes.

    Here are some blog posts explaining the concept. http://shazwazza.com/post/Custom-MVC-routes-within-the-Umbraco-pipeline http://jamessouth.me/archive/fun-with-umbracovirtualnoderoutehandler/

    I don't know if your data comes from Umbraco of a custom db. But let me know what you decide. Maybe I can help you out

    Dave

  • Willem Luijk 24 posts 95 karma points
    Sep 05, 2015 @ 12:21
    Willem Luijk
    0

    Hi Dave,

    Data is coming from the SQL animal table. I expect some thousands or records.

    How do i implement this line from default MVC to an Umbraco friendly statement:

    @Html.ActionLink("Details", "AnimalDetails", new { id = item.AnimalID })
    

    The command here above is in the partial AnimalIndex.

    The partial is activated through a call to the AnimalSurfaceController with the next command:

    @Html.Action("Index", "AnimalSurface")
    

    Back to the statement:

    @Html.ActionLink("Details", "AnimalSurface", new { id = item.AnimalID })
    

    How does the id parameter from the AnimalIndex partial eaches the partial AnimalDetails?

    I need someting like this:

    @Html.Action("Details", "AnimalSurface", new { AnimalID = Request["id"]})
    

    But then the controller result need to be a whole view or Umbraco has to know what template is needed to render the partial...

    By the way, i suppose the MapUmbracoRoute from the example need to be made yourself because i cant find it.

  • Dave Woestenborghs 3504 posts 12134 karma points MVP 9x admin c-trib
    Sep 06, 2015 @ 07:28
    Dave Woestenborghs
    0

    Surface controllers have their own routing , so what your are trying to achieve is not possible. https://our.umbraco.org/documentation/Reference/Routing/surface-controllers

    It think you need virtual nodes like I mentioned in my previous answer.

Please Sign in or register to post replies

Write your reply to:

Draft