Hi
I'm creating a simple list like a bloglist that get content from subpages.
Blog
-subplage1
-subpage2
...
I have created surfacecontroller and i get an error in the Template
@{Html.RenderAction("RenderPuffInfoList", "SiteLayout");}
Can someone help me, thanks!
/C
A Partial View
@model IEnumerable
@foreach (PuffInfoItem item in Model)
{
@RenderPuffInfo(item)
}
A Controller
public class TemaController: SurfaceController
{
private const string PARTIALVIEWFOLDER = "~/Views/Partials/SiteLayout/";
A Model
public class PuffInfoItem
{
public string Header { get; set; }
public string Image { get; set; }
public string Ingress { get; set; }
public string Url { get; set; }
public string Color { get; set; }
Hi and Thanks for helping me
I got this error
@{Html.RenderAction("RenderPuffInfoList", "SiteLayout");}
Cannot create an instance of an interface.
I have a "Root" node following treestructur.
level(2)Home
level(2)Blog
level(3)-subpage1
level(3)-subpage2
level(2)ContactPage
...
In the Controller i have IPublishedContent page as an argument
And collection the subpages with:
var pages = page.Children.Where(m => m.DocumentTypeAlias == "Tema");
Is that right? I'm an newbie in Umbraco and MVC
/C
public ActionResult RenderPuffInfoList(IPublishedContent page)
{
List
var pages = page.Children.Where(m => m.DocumentTypeAlias == "Tema");
foreach (IPublishedContent item in pages)
{
string _Header = page.GetPropertyValue("rubrik").ToString();
I have a feeling, although I'm not 100%, but you cannot have a parameter to an action on a controller as an interface. The ModelsBinder that tries to bind your web request to an action needs to know what type to instantiate. It's an annoying error from MVC, as it allows you to compile the code but throws the error at runtime as you are seeing.
If you need to pass a page to the controller, you are better off passing the page ID, and then retrieving the page in the controller.
Surfacecontroller error
Hi I'm creating a simple list like a bloglist that get content from subpages. Blog -subplage1 -subpage2 ... I have created surfacecontroller and i get an error in the Template @{Html.RenderAction("RenderPuffInfoList", "SiteLayout");}
Can someone help me, thanks! /C
A Partial View @model IEnumerable
A Controller public class TemaController: SurfaceController { private const string PARTIALVIEWFOLDER = "~/Views/Partials/SiteLayout/";
A Model public class PuffInfoItem { public string Header { get; set; } public string Image { get; set; } public string Ingress { get; set; } public string Url { get; set; } public string Color { get; set; }
Hi Christina
What is the error you are getting ?
Nigel
Hi and Thanks for helping me I got this error @{Html.RenderAction("RenderPuffInfoList", "SiteLayout");} Cannot create an instance of an interface.
I have a "Root" node following treestructur. level(2)Home level(2)Blog level(3)-subpage1 level(3)-subpage2 level(2)ContactPage ...
In the Controller i have IPublishedContent page as an argument And collection the subpages with: var pages = page.Children.Where(m => m.DocumentTypeAlias == "Tema"); Is that right? I'm an newbie in Umbraco and MVC /C
public ActionResult RenderPuffInfoList(IPublishedContent page) { List
Hi Christina,
I have a feeling, although I'm not 100%, but you cannot have a parameter to an action on a controller as an interface. The ModelsBinder that tries to bind your web request to an action needs to know what type to instantiate. It's an annoying error from MVC, as it allows you to compile the code but throws the error at runtime as you are seeing.
If you need to pass a page to the controller, you are better off passing the page ID, and then retrieving the page in the controller.
Nik
is working on a reply...