Pass Model Along With ViewData Object In Partial V

2019-08-12 15:42发布

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条回答
Ridiculous、
2楼-- · 2019-08-12 15:59

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.

查看更多
登录 后发表回答