MVC3 紧密耦合视图铸造问题
这是我的对象
public class ProductContent
{
public Product Product { get; set; }
public Location ProductLocation { get; set; }
}
,我有一个与位置对象紧密耦合的视图。
我有一个与 ProductContent 紧密结合的视图 在我的产品内容视图中,我
@Html.Partial("../PartialViews/Location", Model.ProductLocation)
收到一条错误消息,说
The model item passed into the dictionary is of type 'ProductContent', but this dictionary requires a model item of type 'Location'.
我正在传递 Model.ProductLocation,其类型为位置,但为什么它仍然错误关闭?
我正在使用 MVC3 C# Razor
this is my object
public class ProductContent
{
public Product Product { get; set; }
public Location ProductLocation { get; set; }
}
I have a view that is tightly coupled with Location object.
i have a view that is tightly coupled with ProductContent
in my productcontent view i do
@Html.Partial("../PartialViews/Location", Model.ProductLocation)
i get a error saying
The model item passed into the dictionary is of type 'ProductContent', but this dictionary requires a model item of type 'Location'.
I am passing Model.ProductLocation which is of type location but why does it still error off?
I am using MVC3 C# Razor
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是asp.net mvc的
RenderPartial
的一个功能。当您将 null 作为模型传递时,它会使用父视图的模型。ASP.NET MVC、强类型视图、部分视图参数故障
This is a feature of asp.net mvc's
RenderPartial
. When you pass null as a model, it uses the model of parent view.ASP.NET MVC, strongly typed views, partial view parameters glitch