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 ?
Add a comment |
1 Answer
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.
2 Comments
theChampion
So why this is not working in case that the return value of ViewData is ViewDataDictionary ?
haim770
Because the method is expecting last parameter of type
ViewDataDictionary. ViewData is indeed ViewDataDictionary, ViewData['123'] is an object.