Umbraco.Web.Mvc.ModelBindingException: 'Cannot bind source type Umbraco.Web.Models.RenderModel`1[[Umbraco.Web.PublishedContentModels.Home, AppWeball.generated.cs.8f9494c4.moxirk3w, Version=0.0.0.1, Culture=neutral, PublicKeyToken=null]] to model type UmbracoMVC0.Models.CommentViewModel.'
the model is:
public class CommentViewModel
{
//[Required]
public string Name { get; set; }
//[Required]
public string Email { get; set; }
//[Required]
[Display(Name = "Enter a comment")]
public string Comment { get; set; }
}
You are welcome, Sonja. You can use CommentViewModel of course, but you have to pass a model of CommentViewModel type to your partial. Do not use Umbraco helper for rendering partial view.
and there is a textbox with en-us and button Submit Query and when I press the button I'm getting
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.MissingMethodException: No parameterless constructor defined for this object.
Can you please tell me where shall i define this missing parmeter
Hi Alex
It is displaying the form just befor e the form it is displaying the model name and I don't need the model name. Where should I look for the problem? how do i fix this?
Thanks for the form fields
getting a runtime error
Hi,
I have partial view
When I run it I get runtime error
Umbraco.Web.Mvc.ModelBindingException: 'Cannot bind source type Umbraco.Web.Models.RenderModel`1[[Umbraco.Web.PublishedContentModels.Home, AppWeball.generated.cs.8f9494c4.moxirk3w, Version=0.0.0.1, Culture=neutral, PublicKeyToken=null]] to model type UmbracoMVC0.Models.CommentViewModel.'
the model is:
How do I make this work? please advice
Hi Sonja
It looks like you are running this code on a Home page. So you have to use "Umbraco.Web.PublishedContentModels.Home" as a model:
Alex
Thanks Alex, but is there possibility somehow to use my custom model?CommentViewModel
Hi Sonja,
How are you calling your partial view?
Thanks,
Nik
You are welcome, Sonja. You can use CommentViewModel of course, but you have to pass a model of CommentViewModel type to your partial. Do not use Umbraco helper for rendering partial view.
Nik this is how I'm calling the partial view in the home page
Alex I've tried this in the partial view
and I'm getting displayed on the web page
Umbraco.Web.Models.RenderModel`1[Umbraco.Web.PublishedContentModels.Home] UmbracoMVC0.Models.CommentViewModel CurrentCulture
and there is a textbox with en-us and button Submit Query and when I press the button I'm getting
Can you please tell me where shall i define this missing parmeter
Hi Sonja,
Try this way to call partial:
Hi Alex It is displaying the form just befor e the form it is displaying the model name and I don't need the model name. Where should I look for the problem? how do i fix this? Thanks for the form fields
The model name displayed twice I solved this with removing @Model UmbracoMVC0.Models.CommentViewModel
now it is ok. Thanks
Hi Sonja
Thanks for getting back!! Great that this issue has been solved. Have a great day!
Alex Skrypnyk
is working on a reply...