我有問題從控制器返回與我的主視圖不同的模型的部分視圖。例如:HTML.Partial - MVC 3剃鬚刀
public ActionResult Index()
{
//myModel - get Some Types
return View(mymodel);
}
public PartialViewResult Categories()
{
//my another Model - get different Types
return PartialView(myanothermodel);
}
然後在索引視圖:
@Html.RenderPartial("Categories")
我得到一個異常說,這是錯誤的類型。它期望第一種類型(mymodel)而不是第二種類型。
是否有可能返回不同類型的視圖及其部分視圖? 感謝您的回覆。
謝謝!它的作品:) – jars 2011-03-18 00:55:16
@jars:不客氣。你應該通過點擊空心支票來接受這個答案。 – SLaks 2011-03-18 01:14:34
爲什麼'@ Html.Action'?並且'PartialViewResult'是否需要更改爲'ActionResult'。似乎方式就像不使用局部視圖。 – CallMeLaNN 2011-03-18 02:34:38