Question

It would like to iterate through list and render partial view for each element:

<for each="Element elem in elements">
  <render partial="partialViewName">     
</for>

How should I pass elem to partial view? <render partial> doesn't have additional parameters. I can use html.RenderPartial, but I would like to use Spark syntax. Is it possible? It looks as if it needed to use the same ViewData and couldn't define its own model.

EDIT:

Partial view:

${elem.ID} 

OK. I can use 'elem' in partial view, but partial view doesn't know what type 'elem' is. Of course everything will work, because generated view class compiles, but I have no Intellisense in partial view.

Was it helpful?

Solution

<viewdata paramname="paramtype"/>

Also I never used render, I use <use name="partialname" param1="value" param2="value" .../> - maybe it's the same as render, I don't know. But defining your parameters in viewdata as shown above should also work.

Also note the <default /> element, not for this exactly question, but can also be useful since sometimes you'd want some partial parameters to be optional.

OTHER TIPS

Well, I don't use Spark View Engine. But it appears <render partial> does have additional parameters. See here.

So I'm guessing you need to expose a property in your partial view and set its value via with *="" assignments.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top