0

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?

3
  • It may be helpful to paste the code, or some version of it... Commented Dec 7, 2011 at 18:04
  • 2
    We would have to see more of the code for the View. The first list of my RazorView is: @model KB.Web.ViewModels.Deal Commented 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. Commented Dec 7, 2011 at 18:05

2 Answers 2

2

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

Sign up to request clarification or add additional context in comments.

Comments

0

I would also like to point out that in VB the directive is @ModelType vs the directive in C# of @model

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.