I can't seem to get a grasp on how to use the viewdata structure in the spark view engine. I have the following code in my controller:
// Retrieve the project list from the database
var projects = from p in _context.Repository<project>()
orderby p.name ascending
select p;
return View(projects.ToList<project>());
This code works, as I have unit tests returning the correct projects, and my non-spark view worked perfectly. Now I am trying to switch to Spark View Engine and I'm just confused on the syntax. As a side note, I have verified that spark view engine is working and reading my .spark view.
Here is what I am using in my list.spark view:
<h2>Available Projects</h2>
<viewdata model="IList[[project]]"/>
Count: ${model.count}
When rendering this view the following error occurs:
.../List.Spark(3,16): error CS0103: The name 'model' does not exist in the current context
This is referring to the model.count line. Why doesn't this work? I tried passing the project list to the ViewData["projects"] (and replaced model in the spark code with projects) and I get the same error (take out the model.count for projects.count).
This is probably something stupid, but I can't seem to figure this out.
Update:
Well I fixed this. It seems that the MVC2 web.config file created by VS 2010 Beta 2 was bad. I used a MVC2 web.config file created by VS 2010 RC and it now works. Thanks!