开发者

No overload for method 'Write' takes 0 arguments in MVC3 Razor Format,

开发者 https://www.devze.com 2023-02-07 22:31 出处:网络
In My project <% if (Model.Folders != null){}%> is working fine,when i convert this code to razor format ,i got the exception \"No overload开发者_运维问答 for method \'Write\' takes 0 arguments

In My project <% if (Model.Folders != null){}%> is working fine,when i convert this code to razor format ,i got the exception "No overload开发者_运维问答 for method 'Write' takes 0 arguments in MVC3 Razor Format," on my

Html.RenderPartial(ViewData["abc"] as string, Model);

I am Using Dynamic View


In Razor the if test should be like this:

@if (Model.Folders != null)
{
    <div>@Model.Folders</div>
}

and the RenderPartial like this:

@{Html.RenderPartial(ViewData["abc"] as string, Model);}

or you could also use the Partial method which is equivalent and a little shorter:

@Html.Partial(ViewData["abc"] as string, Model)


I have had the same problem, I solved it by wrapping my Html.RenderPartial as follows:

     <text>
         @{
           Html.RenderPartial(ViewData["abc"] as string, Model);
          }
     </text>

or

<div>
@{
Html.RenderPartial(ViewData["abc"] as string, Model);
}
</div>
0

精彩评论

暂无评论...
验证码 换一张
取 消