I would like to pass the data to the view, I created a viewmodel inheriting from RenderModel but when I run to the error "Element" Umbraco.Web.Models.RenderModel "does not contain the definition" Topic "
ViewModel:
namespace Umbraco12.Models
{
public class Home : RenderModel
{
public Home(IPublishedContent content, CultureInfo culture) : base(content, culture)
{
}
public string Topic { get; set; }
}
}
Controller:
public class HomeController : Umbraco.Web.Mvc.RenderMvcController
{
// GET: Home
public ActionResult Home(RenderModel model)
{
var home = new Home(model.Content, model.CurrentCulture);
home.Topic = "aloha";
//Do some stuff here, then return the base method
return View("Home", home);
}
}
At first glance, I wondered if in your view your 'Home' model was the one you have created in the Umbraco12.Models namespace or one generated by ModelsBuilder... as you have a 'using' statement for the auto generated PublishedContentModels, and if your doc type is called Home....
now I have a mistake:
You can not use the type "Umbraco12.Models.Home" as a parameter of the type "TContent" in the general type or the "Umbraco.Web.Mvc.UmbracoTemplatePage
Umbraco custom viewmodel
I would like to pass the data to the view, I created a viewmodel inheriting from RenderModel but when I run to the error "Element" Umbraco.Web.Models.RenderModel "does not contain the definition" Topic "
ViewModel:
Controller:
View:
Hi Niker
At first glance, I wondered if in your view your 'Home' model was the one you have created in the Umbraco12.Models namespace or one generated by ModelsBuilder... as you have a 'using' statement for the auto generated PublishedContentModels, and if your doc type is called Home....
Try
or call your custom ViewModel something like HomeViewModel instead of Home, and that might avoid the clashes, if that is indeed the issue here!
regards
marc
I tried:
now I have a mistake: You can not use the type "Umbraco12.Models.Home" as a parameter of the type "TContent" in the general type or the "Umbraco.Web.Mvc.UmbracoTemplatePage
How about
??
regards
Marc
Marc, you're a beautiful man!
This working, thanks.
is working on a reply...