MVC asp.net PartialView causing No Parameterless constructor error?

Your problem is that the CatalystModel class doesn't have a default constructor so the default model binder cannot instantiate it here: ChildActionOnly public ViewResult SearchView(CatalystModel model) { return View(model); } This being said having such a child controller action that you are invoking like this: % Html. RenderAction("SearchView", ViewData"catalystItems"); % is totally useless and bring strictly no value Why don't you render the partial directly: % Html. RenderPartial("SearchView", ViewData"catalystItems"); % You should also read the Haacked blog post to better understand the differences between RenderAction and RenderPartial Or if you really (for some cryptic reason) have controller actions that take some models which do not have default constructors as action parameters you will need to write a custom model binder for this type and specify which of your custom constructors should be used to instantiate it and what values should be passed to it of course.

Your problem is that the CatalystModel class doesn't have a default constructor so the default model binder cannot instantiate it here: ChildActionOnly public ViewResult SearchView(CatalystModel model) { return View(model); } This being said having such a child controller action that you are invoking like this: is totally useless and bring strictly no value. Why don't you render the partial directly: You should also read the Haacked blog post to better understand the differences between RenderAction and RenderPartial. Or if you really (for some cryptic reason) have controller actions that take some models which do not have default constructors as action parameters you will need to write a custom model binder for this type and specify which of your custom constructors should be used to instantiate it and what values should be passed to it of course.

Thanks for getting back to me so fast here. I had read a while ago that RenderPartial was less used, but I will read that article to get a better uderstanding. As for, the constructor, isn't this what it's asking for with the Model?

/// /// Constructor instantiates SQL DB Connection /// public CatalystModel() { _repository = new CatalystRepository(_connectionString); // Manufactures = GetAllManufactures(); } – user479323 Sep 19 at 22:20 @user479323, I talked about the CatalystModel class which doesn't have a parameterless constructor. I really don't know what you are showing me in your comment. – Darin Dimitrov 23 Sep7 at 22:34 Right but what I'm saying is that I do have a parameterless constructor... it least it seems that way.

See above, I edited my post to include the CatalystModel class.? #region CONSTRUCTOR /// /// Constructor instantiates SQL DB Connection /// public CatalystModel() { _repository = new CatalystRepository(_connectionString); // Manufactures = GetAllManufactures(); } – user479323 Sep 19 at 22:40 Also - the RenderPartial fixed the isue, but I would still like to understand why what did broke – user479323 Sep 19 at 22:40 ok... as much as I appreciate your response, attitude and being a jerk when I'm trying to learn is unnessesary, obviously there is something I am missing when you say parameterless constructor. With that said, can you please explain why public CatalystModel(){} is not a parameterless instructor? Thats what I have in my model clas, is that not what it is looking for?

Thank you in advance. – user479323 Sep 19 at 22:46.

Server Error in '/' Application. No parameterless constructor defined for this object. 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.

Line 54: HttpException (0x80004005): Error executing child request for handler 'System.Web.Mvc. __RenderContent1(HtmlTextWriter __w, Control parameterContainer) in c:\Users\gcoleman\Documents\Source Code\Sandbox\Jonathan Henk\MVC\CINet\CINet\Areas\CatalystSearch\Views\CatalystSearch\List. __Renderform1(HtmlTextWriter __w, Control parameterContainer) in c:\Users\gcoleman\Documents\Source Code\Sandbox\Jonathan Henk\MVC\CINet\CINet\Views\Shared\Site.

Version Information: Microsoft .

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions