I'm currently stuyding MVC-5 ASP.NET and following this tutorial: https://www.youtube.com/watch?v=Fu9v2MIDlTA
I have successfully created my view and controller and therefore my HeLLO WORLD display. Now I'm currently in part 2 of the tutorial wherein I'm passing my data from controller to View.
Here are the codes:
Home Controller:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
namespace WebApplication2.Controllers
{
public class HomeController : Controller
{
//
// GET: /Home/
public ActionResult Index()
{
return View();
}
public ActionResult ShowHome()
{
ViewData["CurrentTime"] = DateTime.Now.ToString();
return View("Home");
}
}
}
View:
@{
ViewBag.Title = "Home";
}
<html>
<head>
<title>
WELCOME TO MVC 5
</title>
<body>
<div>
This is my homepage! <br/>
TIME: <%= ViewData["CurrentTime"]%>
</div>
</body>
</head>
</html>
The question is: Why is it that when I type the part: <% %>, my ide is not reading it? I mean, the speaker in the tutorial is using I think Visual Studio 2013 Ultimate. When he types <% >%, there is intellisense.
I'm using Visual Studio 2013 Express for WEB, when I type
ViewData["CurrentTime"] = DateTime.Now.ToString();
The IDE doesn't recognize it and it prints this as a string. :(
@ViewData["CurrentTime"].<%= ViewData["CurrentTime"]%>has to be changed to@ViewData["CurrentTime"]. BTW I'd drop that tutorial in favor of something newer. Concepts didn't change much but everything else changed a lot...