方法'Write'的重载没有采用MVC3剃刀格式的0个参数, [英] No overload for method 'Write' takes 0 arguments in MVC3 Razor Format,

查看:70
本文介绍了方法'Write'的重载没有采用MVC3剃刀格式的0个参数,的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的项目<% if (Model.Folders != null){}%>中,当我将此代码转换为razor格式时,工作正常,

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);

我正在使用动态视图

推荐答案

在Razor中,if测试应如下所示:

In Razor the if test should be like this:

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

RenderPartial这样:

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

,或者您也可以使用Partial方法,该方法等效且短一些:

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

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

这篇关于方法'Write'的重载没有采用MVC3剃刀格式的0个参数,的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆