title: MVC 3 Changing Model in Views with RenderPage
body: <p>I'm having problems when trying to change the model of my view in MVC 3.</p>
  
  <p>First view (<strong>index.cshtml</strong>) :</p>
  
  <pre><code>@model IEnumerable&lt;MyProgram.MyFrogCollection&gt;
  
  &lt;h1&gt;Welcome to my frog collection&lt;/h1&gt;
  @foreach(MyProgram.Frog frog in Model)
  {
    &lt;div class="frogDetails"&gt;
      @RenderPage("ShowFrogDetails.cshtml", frog);
    &lt;/div&gt;
  }
  </code></pre>
  
  <p>Second view (<strong>ShowFrogDetails.cshtml</strong>), that I would like to use all over the site :</p>
  
  <pre><code>@model MyProgram.Frog
  
  &lt;h3&gt;Name:&lt;/h3&gt;&lt;div class="detail"&gt;@Model.Name&lt;/div&gt;
  &lt;h3&gt;Colour:&lt;/h3&gt;&lt;div class="detail"&gt;@Model.Colour&lt;/div&gt;
  </code></pre>
  
  <p>However when I try to run the page <strong>index.cshtml</strong> after passing in a list of frog objects I get the following error when getting to the @RenderPage line :</p>
  
  <blockquote>
    <p>Server Error in '/' Application. The model item passed into the
    dictionary is of type
    'System.Collections.Generic.List`1[MyProgram.Frog]', but this
    dictionary requires a model item of type 'MyProgram.Frog'.</p>
  </blockquote>
  
  <p>If I were to remove the code from <strong>ShowFrogDetails.cshtml</strong> and place it in-line within the foreach loop of <strong>index.cshtml</strong> the results are what I would expect. However this doesn't reuse existing code.</p>
  
  <p>Is there anyway I can change the model to a single Frog object for use in the RenderPage ?</p>
  
  <p>Cheers!</p>