Reputation: 4004
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?
Upvotes: 0
Views: 232
Reputation: 596
Just return the view,and serialize the data to json,then pass the json data to the view. Operate the json data with javascript in the page.
Upvotes: 2