This is my first MVC project. I am building a Bing Map application (that loads multiple pushpins on the map).
Here's my Index ActionResult
public ActionResult Index(string Id)
{
// Here is the code to populate the DataSet using Id parameter
DataTable dtReport = ds.Tables[0];
List<MapPoint> points = new List<MapPoint>();
int index = 1;
foreach (DataRow r in dt.Rows)
{
points.Add(GetPointInfo(r, false));
index++;
}
//return the list as JSON
return Json(points, JsonRequestBehavior.AllowGet);
}
My problem is, when I go to the Index view, all I see is the Json formatted data and the map disappears. I would assume this happens because I am returning JsonResult in the Index ActionResult.
Is there any way I can retain the map on the View and still be able to pass JsonResult to the Index view and access it using jQuery?
view dataand you can use theview data resultin javascript. make sure your action returns view and not json.