1

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 Answer 1

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.

Sign up to request clarification or add additional context in comments.

2 Comments

So why this is not working in case that the return value of ViewData is ViewDataDictionary ?
Because the method is expecting last parameter of type ViewDataDictionary. ViewData is indeed ViewDataDictionary, ViewData['123'] is an object.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.