I'm trying to use IPublishedContent in my controller so instead of Model.Content I want to just call Model
In the view, you just use
inherit UmbracoViewPage<IPublishedContent> instead of UmbracoTemplatePage
Currently my controller is this in the most simple form
using System.Web.Mvc;
using Umbraco.Web.Models;
namespace test.Controller
{
public class TestDocument : Umbraco.Web.Mvc.RenderMvcController
{
public override ActionResult Index(RenderModel model)
{
return base.Index(model);
}
}
}
Also, how do i get property values here, I have tried the default Model.Content.GetPropertyValue<string>("valueHere"); or model.Content.GetPropertyValue<string>("valueHere"); wat but its not having that?
IPublishedContent in Controller
Hi,
I'm trying to use IPublishedContent in my controller so instead of
Model.ContentI want to just callModelIn the view, you just use
inherit UmbracoViewPage<IPublishedContent>instead ofUmbracoTemplatePageCurrently my controller is this in the most simple form
Also, how do i get property values here, I have tried the default
Model.Content.GetPropertyValue<string>("valueHere");ormodel.Content.GetPropertyValue<string>("valueHere");wat but its not having that?Thanks, Lewis
You can get the current page like this:
Jeroen
model.Content is IPublishedContent, so you should be able to use .GetPropertyValue
Other option: use CurrentPage, which is also IPublishedContent
Cheers,
--Dirk
Hi Great! It worked!
How would I then get this property in my view?
Lewis
Exactly the same way, you said your view is now a
so Model will be of IPublishedContent. Again, adding the import statement should be enough to get this working in the view
--Dirk
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.