0

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.

LukLed
  • 31,452
  • 17
  • 82
  • 107

2 Answers2

1

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.

Çağdaş Tekin
  • 16,592
  • 4
  • 49
  • 58
1

<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.

queen3
  • 15,333
  • 8
  • 64
  • 119
  • This is the same as render. I prefer render, because its name is more appealing to me. I don't know why I didn't use , it seems obvious. Thank you. – LukLed Oct 24 '09 at 23:18