3

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?

hutchonoid
  • 31,459
  • 14
  • 91
  • 100
Alex
  • 762
  • 1
  • 7
  • 19

2 Answers2

5

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

Community
  • 1
  • 1
Erik Philips
  • 48,663
  • 7
  • 112
  • 142
2

No, just add the model directive in Partial 2:

@model int
@if(Model == 50)
{
     <div>50 Was Passed In</div>
}
hutchonoid
  • 31,459
  • 14
  • 91
  • 100