This article introduces a different concept of the view engine - a client-side view engine that renders a view in a client browser. In this concept, the model and the controller are still on the server-side. However, instead of the HTML, JSON is generated as an output from the server-side, it is accepted on the client-side, and HTML is generated using the JavaScript templating engine.
|
using System.Linq;
using System.Web.Mvc;
using LoadJSON.Models;
namespace LoadJSON.Controllers
{
public class CompanyController : Controller
{
public ActionResult List()
{
return Json(DataRepository.GetCompanies(), JsonRequestBehavior.AllowGet);
}
public ActionResult Data(int? ID)
{
return Json(DataRepository.GetCompanies().First(c => c.ID == ID), JsonRequestBehavior.AllowGet);
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Graduated from Faculty of Electrical Engineering, Department of Computer Techniques and Informatics, University of Belgrade, Serbia.
Currently working in Microsoft as Program Manager on SQL Server product.
Member of JQuery community - created few popular plugins (four popular JQuery DataTables add-ins and loadJSON template engine).
Interests: Web and databases, Software engineering process(estimation and standardization), mobile and business intelligence platforms.