Reputation: 23
have a layout page and trying to place a view rendering statically over it. And also need to pass the data source to it, like this
@Html.Sitecore().ViewRendering("/Views/Renderings/Components/LightboxModal.cshtml", new { DataSource = "/sitecore/content/Common Content/Medicare Disclaimer" });
But am getting this error,
The model item passed into the dictionary is of type 'Sitecore.Mvc.Presentation.RenderingModel', but this dictionary requires a model item of type 'Web.Data.Models.LightboxModel'.
Do anyone a solution for this ?
Thanks
Upvotes: 2
Views: 1347
Reputation: 379
Looks like you have Humana.Hri.Wellness.Web.Data.Models.LightboxModel set as the Model in your cshtml but your Model field on the ViewRendering sitecore item is empty.
You need to create a Model item under /layouts/models in the content tree and map it to Humana.Hri.Wellness.Web.Data.Models.LightboxModel type. Then in your ViewRendering item link to that Model item.
This way you will be passing the correct type to your ViewRendering.
When the Model field is left empty Sitecore assumes the default model for your ViewRendering is the RenderingModel(default sitecore model)
Upvotes: 5