Question

I am having a play around with the different view engines that one can use with ASP.net MVC. I am trying out Spark, but I am stuck on how I can get my View to be Strongly typed.

I have done the following:

<viewdata message="string" model="ComparingViewsSparkEngine.Models.LogOnModel" />

And within my view I have changed anything like this:

@Html.LabelFor(m => m.UserName)

to be Sparky like so:

${Html.LabelFor(m => m.UserName)}

But I am getting an error that says:

Dynamic view compilation failed. c:\Users\Ciwan\Documents\Visual Studio 2012\Projects\ComparingViewsSparkEngine\ComparingViewsSparkEngine\Views\Account\LogOn.spark(19,17): error CS1056: Unexpected character '$'

Was it helpful?

Solution

Update

As of the last version of the code you have this:

${using (Html.BeginForm()) {

it needs to change to this:

#using (Html.BeginForm()) {

because you're trying to write a line of pure C# code. And also then your last line can be #} instead of #}}


Not sure if this is the problem - but it looks like you haven't closed the } on Validation Summary on line 11.

And I'm pretty sure you'll also have to end the view with #}} rather than }} because the # denotes a raw line of code when you don't have a $ to start the code off.

To get around the ugly #}} stuff, I usually use Spark Bindings - you can check out my blog post on it.

OTHER TIPS

In the end I couldn't get the using this to work:

${using (Html.BeginForm()) {

So instead I just used regular HTML form tags and it now works:

<form> // form stuff here </form>

Not ideal, but at least I'm not getting the error, and the page seems to be working.

Thanks

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