c# - Pass Additional ViewData to a Strongly-Typed Partial View -


I have a firmly typed partial view that takes the product image and when it is provided I I would like to provide additional extravagance which I've dynamically created in the page I created. In partial view with RenderPartial call, how can I easily pass both my typed object and my custom watchdata?

  var index = 0; Forchcha (images in the model, picture .orderbie (p = & gt; p. Oder)) {html.renderpartial ("product image", image); // & lt; Pass the 'index' from the partial index ++; Renderpartal takes another parameter that is only a ViewDataDictionary.  

You are almost there, just call it like this:

  HTML. Renderparty ("Product Image", Image, New ViewDataTine {{"Index", Index}});  

Note that this will override the default view, which is by default all your other views. If you are adding ViewData to something, it will not be in this new dictionary that you are going through your partial view.


Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -