Easiest way to pass data to a partial view FROM a partial view

asp.net, asp.net-mvc, asp.net-mvc-3, c#, razor

Solution

Partial and RenderPartial don't require a controller. Action and RenderAction require a controller.

So your code in partial 2 should be:

@model int

@if(Model == 50)
{
 <div>50 Was Passed In</div>
}

Also a good read is Html.Partial vs Html.RenderPartial & Html.Action vs Html.RenderAction

Problem

Code in partial 1 file: ``` @Html.Partial("Partial2", 50) ``` Code in partial 2 file: ``` @if(passed in parameter == 50) { <div>50 Was Passed In</div> } ``` Does this really require me to create a new controller?

Original source

Related problems