I have created a simple class which contains three properties
ID
Name
Amount
i have passed the namespace of model to controller class, as
public class _1Controller : Controller
{
//
// GET: /1/
Customer objCustomer = new Customer();
public ActionResult Index()
{
ViewData["CurrentTime"] = DateTime.Now.ToString();
return View();
}
public ViewResult DisplayCustomer()
{
Customer objCustomer = new Customer();
objCustomer.ID = 12;
objCustomer.Name = "1001";
objCustomer.Amount = 90.34;
return View("DisplayCustomer", objCustomer);
}
}
when i have bind the controller class to a view,as
@model MvcApplication4.Models.Customer
@{
Layout = null;
}
<html>
<head>
<title>DisplayCustomer</title>
</head>
<body>
<div>
The customer id is <%= Model.Id %> <br />
the customer Name is <%= M
</div>
</body>
</html>
when i am trying to call class properties, it doesn’t show.
i have clicked the strongly typed checkbox while binding the view to a controller.Thanks for any assistance.
MVC3 has a number of razor Html helper methods to accomplish this.
Instead of
try this
Here is a list of these helper on MSDN