Pass Model Along With ViewData Object In Partial View

三世轮回 提交于 2019-12-24 12:51:36

问题


I want to pass Model along with some object stored in ViewData dictionary. The way I did this is @Html.Partial("_DataPaging", Model, ViewData['123']). But this gives an error that Partial method has some invalid arguments. How can I pass Model along with some other object which I want to use inside Partial View ?


回答1:


Seems like the appropriate overloaded method signature of the Html.Partial method is:

public static MvcHtmlString Partial(this HtmlHelper htmlHelper,
                                    string partialViewName,
                                    object model,
                                    ViewDataDictionary viewData);

And in your case:

@Html.Partial("_DataPaging", Model, ViewData)

That means you'll have to extract ViewData["123"] manually inside _DataPaging partial.



来源:https://stackoverflow.com/questions/20370669/pass-model-along-with-viewdata-object-in-partial-view

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!