Note that there are some explanatory texts on larger screens.

plurals
  1. POMaking changes to MOVIE list MVC tutorial - Adding a new partial view
    text
    copied!<p>I am following this tutorial to learn basic MVC <a href="http://www.asp.net/mvc/tutorials/create-a-movie-database-application-in-15-minutes-with-asp-net-mvc-cs" rel="nofollow">Movie List Tutorial in MVC</a> I am at the end of the tutorial. Now I want to do my own modification to this tutorial. First, I want to add a new partial view to this movie list view. So in a DIV, I put the following code in the index page that already renders the movie list.</p> <pre><code> @{Html.RenderPartial("_NewPartialView");} </code></pre> <p>For this to work, first in the Models folder, I create a new model class for NewClass.cs. The model folder already has a Movie Model Class.Movie.cs Question1 : Should I be creating a separate Model .cs file for the new partial view or Should I create additional classes in the same Movie.cs file? </p> <p>Then I created a partial view using scaffolding based on the new Model (for now I have the new model in a separate .cs file - meaning I now have two Models one for Movies and one for the NewModel (for partialview). I want this rendered in the original movie list index page as a partial view on the side. </p> <p>I have a MoviesController that has the code</p> <pre><code> public ViewResult Index() { return View(db.Movies.ToList()); } </code></pre> <p>Am I missing anything else? If I try to run this, it is breaking at the line of code</p> <pre><code> @{Html.RenderPartial("_NewPartialView");} </code></pre> <p>and the error message I get at this point of the code is "The model item passed into the dictionary is of type System.Collections.Generic.List<code>1[Project.Models.Movie]', but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable</code>1[Project.Models.NewModel]'.</p> <p>I need some MVC expert guidance in this step of adding a new partial view based on a new model to an existing View/Model. I need help and appreciate any tid bits of information that will help me learn. Thank you</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload