vs 2013 express for web
I have an MVC 4 web app and a WebAPI service returning JSON formatted data.
I tried to use Ajax.BeginForm to call the WebAPI service.
It does call it correctly
@model IEnumerable<MyApp.Models.SomeClass>
@using (Ajax.BeginForm(
new AjaxOptions
{
HttpMethod = "get",
Url="api/MyWebAPI",
InsertionMode = InsertionMode.Replace,
UpdateTargetId = "Resultlist"
}))
{
<div class="row">
<div class="col-lg-12">
<h3>Service Call Details - Method A</h3><inputtype="submit"class="btn btn-default"value=" Get Via Asynch Method A "/></div></div>
}
<divid="ResultList"><tableclass="table"><tr><th>
@Html.DisplayNameFor(model => model.Name)
</th><th>
@Html.DisplayNameFor(model => model.Caption)
</th><th>
@Html.DisplayNameFor(model => model.Description)
</th><th>
@Html.DisplayNameFor(model => model.Active)
</th></tr>
@foreach (var item in Model)
{
<tr><td>
@Html.DisplayFor(modelItem => item.Name)
</td><td>
@Html.DisplayFor(modelItem => item.Caption)
</td><td>
@Html.DisplayFor(modelItem => item.Description)
</td><td>
@Html.ActionLink("Edit", "Edit", new { id = item.ClassifierGroupId }) |
@Html.ActionLink("Details", "Details", new { id = item.ClassifierGroupId }) |
@Html.ActionLink("Delete", "Delete", new { id = item.ClassifierGroupId })
</td></tr>
}
</table>
</div>
But the results don't fill the form.
Now, when the data came from the Home controller's Index function, that returned data as a View with model as an ActionRequest...:
public ActionResult Index()
{
ViewBag.Title = "Home Page";
IEnumerable<SomeClass> model = db.SomeClasses.ToList();
return View(model);
}
So how do I convert the WepAPI returned JSON data to something that the razor form can use for the Model data?
Any help appreciated.
GS
![Sniff | :^)]()
GaltSalt
maker of .Net thingys