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
  • 67,189
  • 30
  • 193
  • 221
sarsnake
  • 24,929
  • 58
  • 173
  • 284

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
  • 67,189
  • 30
  • 193
  • 221
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
  • 25,202
  • 5
  • 61
  • 75