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.