Copied to clipboard

Flag this post as spam?

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


  • Claushingebjerg 939 posts 2574 karma points
    Mar 21, 2014 @ 14:53
    Claushingebjerg
    1

    Partial views vs Partial view macros

    Im a bit late to the entire MVC Party. But with 7.1 its time to get into it.

    Could someone give a very short "frontender" explanation about the difference between partial views and partial view macros?

    When creating either, the same basic templates are available...
    When using a macro, its possible to insert it into the template using the "Insert Macro" button.
    Not so with the partial view... So whats the syntax for inserting a partial view?

    And why use one over the other? Should i, as a basic frontender just keep to using the macros?

     

     

     

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Mar 21, 2014 @ 15:02
    Dennis Aaen
    0

    Hi Claus,

    The syntax for inerting a partial view is like this:

    @{Html.RenderPartial("NameOfPartialView"); }

    Here is a post by Doug that´s give a good explanation: http://our.umbraco.org/forum/developers/razor/44664-Confused-over-when-DynamicNodeList-is-returned

    And here are some more information about Partial views: http://our.umbraco.org/documentation/Reference/Mvc/partial-views

    Hope this helps,

    /Dennis

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Mar 21, 2014 @ 15:02
    Jan Skovgaard
    0

    Hi Claus

    You can find some information here

    Hope this helps :)

    /Jan

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Mar 21, 2014 @ 15:13
    Jan Skovgaard
    100

    ...Warren has also done a blogpost about partials as well. Enjoy!

    /Jan

  • Claushingebjerg 939 posts 2574 karma points
    Mar 21, 2014 @ 15:34
    Claushingebjerg
    0

    I think im gonna read Warrens blog from end to end. It helped me out on the basics of views as well.

    Thanks

  • ed beltran 2 posts 22 karma points
    Mar 23, 2014 @ 19:22
    ed beltran
    0

    this might not be the place to put this, but the mvc partials documentation page( http://our.umbraco.org/documentation/reference/templating/macros/Partial-View-Macros/ ) has no discussion portion to it.

    i followed the code pattern to implent a simple html table. i am gettig my partial to render on the page, but it replicated four times. is the documentation on this subject which does not open issues?

  • Blake Watt (Clerke) 106 posts 351 karma points MVP 2x
    Mar 25, 2014 @ 16:08
    Blake Watt (Clerke)
    0

    Just curious about @Dennis post for rendering a partial. He mentions using 

    @{Html.RenderPartial("NameOfPartialView");}

    would their be a downfall to using the following to render a partial?

    @Html.Partial("NameOfPartialView", Model)

    I'm just curious if there is a difference & if one way is preferred over the other.

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Mar 25, 2014 @ 17:27
    Dennis Aaen
    0

    Hi Blake,

    I don´t think there any difference, if you see the documentation the use the syntax that you mentions. http://our.umbraco.org/documentation/Reference/Mvc/partial-views.

    My example on how to render a partial are taken from the Txt starter-kit, that you can install in the version 7 of Umbraco.

    /Dennis

  • Blake Watt (Clerke) 106 posts 351 karma points MVP 2x
    Mar 25, 2014 @ 19:04
    Blake Watt (Clerke)
    0

    thank you, ill take a look at that.

  • Bjørn Fridal 274 posts 784 karma points
    Mar 25, 2014 @ 19:21
    Bjørn Fridal
    2

    Hi,

    There's a good comparison of the different ways to render a view with pros and cons here: http://www.dotnet-tricks.com/Tutorial/mvc/Q8V2130113-RenderPartial-vs-RenderAction-vs-Partial-vs-Action-in-MVC-Razor.html

    Cheers
    Bjørn 

  • Donald St. Martin 83 posts 128 karma points
    Mar 28, 2014 @ 17:16
    Donald St. Martin
    2

    A little bit late to the game here but here is the basis for how I determine if I use Partial Views or Partial View Macro Files. (I learned this at the latest Version 7 Masterclass last week because I had the same question.) 

    If you have to pass a parameter, then you want to use Partial View Macro Files as it is wrapped in a macro and can support taking a paramater passed from your template. If you don't need to pass a parameter to your view, then a Partial View is used. 

    On a side note, Scripting Files aren't needed anymore as they are replaced by Partial Views and Partial View Macro Files.

  • Mark Gil Libres 24 posts 113 karma points
    Nov 20, 2014 @ 06:35
    Mark Gil Libres
    0

    you can also try my approach which is explained in detail here

    This is making use both partial and macro altogether, but still it depends on your needs

Please Sign in or register to post replies

Write your reply to:

Draft