4

My partial view, called _myTestView.cshtml

<div style="border:1px solid red;">

TEST

</div>

I call it like that

<div>
  @Html.RenderPartial("_myTestView");
</div>

I get the following run time error

Compiler Error Message: CS1502: The best overloaded method match for 'System.Web.WebPages.WebPageExecutingBase.Write(System.Web.WebPages.HelperResult)' has some invalid arguments

What am I doing wrong?

Brandon
  • 68,708
  • 30
  • 194
  • 223
sarsnake
  • 26,667
  • 58
  • 180
  • 286

2 Answers2

3

You're not inside a code block, so you don't use .RenderPartial

Just use .Partial and get rid of the ;

<div>
  @Html.Partial("_myTestView")
</div>
Brandon
  • 68,708
  • 30
  • 194
  • 223
1

Put it inside a code block

@{Html.RenderPartial("_myTestView");}

related What is the difference (if any) between Html.Partial(view, model) and Html.RenderPartial(view,model) in MVC2?

Community
  • 1
  • 1
dotjoe
  • 26,242
  • 5
  • 63
  • 77