Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

mvc list to jsonresult

[HttpPost]
public JsonResult GetAreasForCompany(int companyId)
{
  var areas = context.Areas
    .Where(x => x.Company.CompanyId == companyId)
    .Select(a => new
    {
      AreaId = a.AreaId,
      Title = a.Title
    });
  return Json(areas);
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #mvc #list #jsonresult
ADD COMMENT
Topic
Name
5+6 =