Copied to clipboard

Flag this post as spam?

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

  • James Jackson-South 489 posts 1746 karma points c-trib
    May 06, 2014 @ 18:02
    James Jackson-South

    What is the difference between UmbracoViewPage and UmbracoTemplatePage

    As the title says...

    My guess would be that UmbracoTemplatePage is for partial views since there are less properties exposed but I don't really know what the underlying ideology is.

  • Jeavon Leopold 3061 posts 13489 karma points MVP 9x admin c-trib
    May 06, 2014 @ 18:10
    Jeavon Leopold

    Hi James,

    UmbracoTemplatePage is mostly a convenience, it is the same as UmbracoViewPage<RenderModel> except it also has the CurrentPage dynamic property which is the dynamic model of Model.Content


  • Stephen 767 posts 2272 karma points c-trib
    May 06, 2014 @ 18:12

    Trying to summarize the differences:

    UmbracoViewPage<TModel> : WebViewPage<TModel>
    UmbracoViewPage : UmbracoViewPage<IPublishedContent>

    UmbracoTemplatePage : UmbracoViewPage<RenderModel>
    UmbracoTemplatePage<TContent> : UmbracoViewPage<RenderModel<TContent>>

    All of them have the same Umbraco helper, etc. so Umbraco.Field(...) will work with both.

    UmbracoTemplatePage model is a RenderModel (having a Content property which is of type IPublishedContent) or a RenderModel<TContent> (having a Content property which is of type TContent). So Model.Content is a strongly-typed content. In addition, UmbracoTemplatePage adds a CurrentPage property which is a dynamic.

    UmbracoViewPage is clever: depending on whether your view inherit from UmbracoViewPage<IPublishedContent> or UmbracoViewPage<RenderModel>> the model will be directly the IPublishedContent, or a RenderModel instance.

    Now which one should one use?

    In my mind, if you don't plan on using the dynamic CurrentPage property then using UmbracoViewPage makes sense, and then Model is your current content. OTOH if you want the dynamic CurrentPage property, you'll want UmbracoTemplatePage. And the generic versions are for future usage, when we'll be able to use UmbracoViewPage<NewsItem> where NewsItem would be a strongly-typed implementation of IPublishedContent corresponding to content type "news item" -- but that is not working at the moment in 7.1.

    Making sense?

  • James Jackson-South 489 posts 1746 karma points c-trib
    May 06, 2014 @ 18:29
    James Jackson-South

    Thanks for that guys. Much clearer now.

  • Manjunatha Govindappa 20 posts 119 karma points
    Jul 30, 2016 @ 09:13
Please Sign in or register to post replies

Write your reply to: