Ticket #29 (closed defect: fixed)

Opened 4 months ago

Last modified 4 months ago

ViewData Variable Scope

Reported by: Chadley Assigned to:
Priority: major Component:
Keywords: Cc:

Description

I'm just wondering what the best practice would be for the following situation.

I have a view which renders a partial view and defines some viewdata.

<viewdata product="Product" /> <div>

<use file="my-partial-view" />

</div>

The partial view looks like this:

<viewdata product="Product" /> ...view contents...

That gives me a compilation error because there are now two product properties defined in the generated class. So, I have to get rid of the <viewdata product="Product" /> in the partial file.

However, I also use that partial file as the rendered view for an ajax request. So, during the ajax request, that view compilation fails saying that there is no member 'product' defined.

What would be the best way to accomplish what I am trying to do? Ideally, I'd like to keep the <viewdata product="Product" /> in both files and just have Spark be smart enough to only generate the property in the class one time. Or maybe Spark should generate a separate class file for each view (rather than merging partial views with their parents) so that clashes like this won't happen?


(Lou) Having Spark de-duplicate would be very simple. It could throw an exception if the types don't match.

Change History

07/30/08 02:33:42 changed by louis.dejardin

  • status changed from new to closed.
  • resolution set to fixed.

The "type" of the view data must be exactly the same from a string-comparison standpoint or an exception is thrown.