Copied to clipboard

Flag this post as spam?

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


  • pat 124 posts 346 karma points
    Mar 15, 2017 @ 13:24
    pat
    0

    partial view macro file load view but surface controller does not execute Index method on page load

    Hi all, I have asked this question few times on different ways , I haven't got any answer.

    I have build a visual studio project with umbraco dlls and created a surface controllers for two three forms and data display grid from another external data source.

    In login controller , Index method look for values on login request and pass customize message to end user with login form. another controller Index method read data from external data source and display in a table.

    both views hit Index method if i call them in Template using Html.Action method. but if I use macro view partial file and use renderpartial to load views and then insert macro in a content page using RTE (rich text editor) that does not hit index method i get blank view.

    How do I approach Index method if i am using macro ?

    please send me your ideas , would be a great help.

  • Marc Goodson 2155 posts 14408 karma points MVP 9x c-trib
    Mar 16, 2017 @ 20:10
    Marc Goodson
    0

    Hi Pat

    I think you still need to use Html.Action to render the controllers within your Macro Partial.

    eg

    If your surface controller is like so:

     public class TestSurfaceController : SurfaceController
        {
            // GET: TestSurface
       public ActionResult HelloCats()
            {
                return PartialView("HelloCats");
            }
        }
    

    and then

    in your Macro you have a Macro Partial

    @inherits Umbraco.Web.Macros.PartialViewMacroPage
    
    <h2>My Macro</h2>
    @Html.Action("HelloCats","TestSurface")
    

    Then when you insert this macro into a rich text area, the surface controller action is hit and renders the result within the macro and the template, in this example...

    enter image description here

Please Sign in or register to post replies

Write your reply to:

Draft