HLRosenberger
asked on
Help with C#, MVC, razor.
I'm a VB.NET/WEB forms guy learning C# and MVC. I created a simple project following an online video. I'm stuck on the code below. I set ViewData in the controller C# code.\, and now I want to show it in the view. In the video, I can see that syntax-wise it highlights the <% %> characters and at run time displays the correct data. But in my project, I get no such highlighting and the literal data shown below is displayed. What am I doing wrong?
Time is <% = ViewData["time"]%>
Time is <% = ViewData["time"]%>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
You are correct. Below code worked. Now the question is why the different syntax, and how/why it work in the video I watched. Maybe a different version of MVC? different version of Razor? etc...
<div>
Time is @ViewData["time"]
</div>
<div>
Time is @ViewData["time"]
</div>
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Razor was introduced as the view engine starting with MVC 3. Perhaps the video is using older than MVC 3.
MVC 4 is the current version if you're using .NET 4
MVC 5 is the current version if you're using .NET 4.5
MVC 4 is the current version if you're using .NET 4
MVC 5 is the current version if you're using .NET 4.5
ASKER
Thanks!
ASKER