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 ?
Asked
Active
Viewed 2,096 times
1

theChampion
- 4,207
- 7
- 28
- 35
1 Answers
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.

haim770
- 48,394
- 7
- 105
- 133
-
So why this is not working in case that the return value of ViewData is ViewDataDictionary ? – theChampion Dec 04 '13 at 09:00
-
1Because the method is expecting last parameter of type `ViewDataDictionary`. `ViewData` is indeed `ViewDataDictionary`, `ViewData['123']` is an `object`. – haim770 Dec 04 '13 at 09:06