C# MVC3 Tighlty耦合视图转换问题
这是我的目标C# MVC3 Tighlty耦合视图转换问题,c#,asp.net-mvc,asp.net-mvc-3,razor,tightly-coupled-code,C#,Asp.net Mvc,Asp.net Mvc 3,Razor,Tightly Coupled Code,这是我的目标 public class ProductContent { public Product Product { get; set; } public Location ProductLocation { get; set; } } 我有一个与位置对象紧密耦合的视图 我的观点与ProductContent密切相关 在我的productcontent视图中,我是这样做的 @Html.Partial("../PartialViews/L
public class ProductContent
{
public Product Product { get; set; }
public Location ProductLocation { get; set; }
}
我有一个与位置对象紧密耦合的视图
我的观点与ProductContent密切相关
在我的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,它的类型是location,但为什么它仍然会出错
我正在使用MVC3 C#Razor这是asp.net mvc的
RenderPartial
的一个功能。当您将null作为模型传递时,它将使用父视图的模型
视图中的@model指令是什么?@model ProjectName.Models.DAO.location我想
model.ProductLocation
是null@driushkin:错误消息听起来不像是空错误。@Natasha Thapa:请显示视图的模型声明。