Copied to clipboard

Flag this post as spam?

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


  • Mehrdad 22 posts 71 karma points c-trib
    May 01, 2016 @ 13:07
    Mehrdad
    0

    I have created an MVC Partial View using SurfaceController. It works well. But I want to insert it in a Gird.

    My Questions:

    • I think I should create a macro then call that controller action using Html.Action and then insert the macro into grid. I just wondering if this way is correct and best practice.

    • Also when I tried to do that, I was unsuccessful as I always receive Error loading Partial View script. If this way is correct, I really appreciate it if you show me an example or tutorial.

  • Dennis Adolfi 1075 posts 6433 karma points MVP 4x c-trib
    May 01, 2016 @ 17:58
    Dennis Adolfi
    0

    Hi Mehrdad!

    You could definitely insert your partial through a macro, I think that's a good solution when you need it in RTE/Grid.

    About your error, that's a generic error message that always shows when a macros fails, so that it won't expose sensitive info. The complete error message can be found in the log file, check /App_Data/Logs. (My guess is a missing namespace.)

    Best of luck to you, let me know if you need anything else!!

  • Mehrdad 22 posts 71 karma points c-trib
    May 02, 2016 @ 06:43
    Mehrdad
    0

    Thanks Dennis,

    You were right, Eventually I created my first macro using MVC. Now I faced another issue. When I create a local surfacecontroller it works well. Then I created a new directory in App_Plugins and added Views and MacroPartials and added my view to this views folder. It works properly but if I add PluginController attribute, it gives this error: No route in the route table matches the supplied values.

    Thanks again for your help.

  • Dennis Adolfi 1075 posts 6433 karma points MVP 4x c-trib
    May 02, 2016 @ 07:39
    Dennis Adolfi
    0

    Strange. Did you do as explained on this page: https://our.umbraco.org/documentation/reference/routing/surface-controllers (Bottom part "Plugin based controllers")

    Could it be that you have to restart the app-pool so that all routes are re-routed?

    Also you are awear that when you make a surfacecontroller to a plugin controller the URL changes?

    Without the Plugincontroller attributre:

    /umbraco/surface/{controllername}/{action}/{id}
    

    With the plugincontroller attribute:

    /umbraco/{areaname}/{controllername}/{action}/{id}
    
  • Mehrdad 22 posts 71 karma points c-trib
    May 02, 2016 @ 07:53
    Mehrdad
    0

    Thanks Dennis,

    Just wondering, I want to use that plugin, on Macro using @Html.Action("Index","Search") Should I change anything when I convert SearchController to Plugin?

  • Dennis Adolfi 1075 posts 6433 karma points MVP 4x c-trib
    May 02, 2016 @ 08:08
    Dennis Adolfi
    101

    Yes you can call it like that but you have to specify your area name i.e the name you´ve given your plugin.

    @Html.Action("Index", "Search", new { area = "MyPlugin" })
    

    if you used this this attribute for the surfacecontroller:

    [PluginController("MyPlugin")]
    
  • Mehrdad 22 posts 71 karma points c-trib
    May 03, 2016 @ 01:46
    Mehrdad
    0

    Thanks Dennis,

    You are expert. All your responses helped me too much.

  • Dennis Adolfi 1075 posts 6433 karma points MVP 4x c-trib
    May 03, 2016 @ 06:18
    Dennis Adolfi
    0

    Hi Mehrdad!

    Awsome, glad to hear that it worked out for you. Good luck with the rest of your plugin!! Have a great day!! :)

Please Sign in or register to post replies

Write your reply to:

Draft