This is a syntax question that I can't figure out because I am new to MVC and the razor view engine. I've wrote a directive in a view with a master layout. The directive is @model Demo.ViewModels.Shared.Grid and asp.net is expecting a ";" somewhere. Consequently, I getting an invalid expression and the view isn't call my class properly. What am I doing wrong?
-
It may be helpful to paste the code, or some version of it...Shlomo– Shlomo2011-12-07 18:04:23 +00:00Commented Dec 7, 2011 at 18:04
-
2We would have to see more of the code for the View. The first list of my RazorView is: @model KB.Web.ViewModels.DealNick Bork– Nick Bork2011-12-07 18:05:04 +00:00Commented Dec 7, 2011 at 18:05
-
Can you give some example code? If you declare the @model on top of the page there shouldn't be any problem.Megacan– Megacan2011-12-07 18:05:53 +00:00Commented Dec 7, 2011 at 18:05
Add a comment
|
2 Answers
You didn't share much information about your problem, however your question can still be answered.
Many times, new MVC users write @{ } instead of @(). The @{} is a code block, so each line of code within the block must end with a semicolon ;, like regular C# code. Whereas @() renders to the response the result of the code, and doesn't require anything contained in it to end with a semicolon ;.