> In a general scenario, when you use Html.Partial;
Html.Partial("partialViewName");
The Model that is sent for parentView, can be used for in the partialViewName. Moreover, the ViewData which is send for parentView can also be used for partialViewName.
> As a special case, when you use Html.Partial and if you want to send Model..
Html.Partial("partialViewName", newModel);
You cannot reach the Model which was sent for parentView.
Therefore, from now on the Model which is active in the partialViewName is the newModel.
The viewData which is send for parentView can be used also for partialViewName.
> As a special case, when you use Html.Partial and if you want to send ViewDataDictionary..
The Model which is send for parentView can be used also for partialViewName
I.
@Html.Partial("partialViewName", new ViewDataDictionary { { "key", value }, { "key2", value2 } })
Here, the ViewData which was sent for parentView overwrite by 'new ViewDataDictionary'.
Here, If there is a ViewBag which is for parentView, you cannot reach that if you write the code like above one.
II.
ViewDataDictionary viewDataDictionary = new ViewDataDictionary();
viewDataDictionary.Add("key", value);
viewDataDictionary.Add("key2", value2);
@Html.Partial("partialViewName", viewDataDictionary)
This usage is same as first one (I.).
III.
ViewDataDictionary viewDataDictionary = ViewData; //If you use this code block, ViewBag which is sent for parent View is not lost.
viewDataDictionary.Add("key", value);
viewDataDictionary.Add("key2", value2);
@Html.Partial("partialViewName", viewDataDictionary)
With this code block, You can reach the ViewData and ViewBag which are sent for parentView in the partialViewName