Posting data using AJAX
- by ognjenb
public ActionResult Create()
{
return View();
}
//
// POST: /Partial/Create
[HttpPost]
public ActionResult Create(last_name ln)
{
try
{
// TODO: Add insert logic here
proba.AddTolast_name(ln);
proba.SaveChanges();
return View();
}
catch
{
return View();
}
}
Part of index View:
<div id="Div1">
<% using (Ajax.BeginForm("Create", new AjaxOptions { UpdateTargetId = "Div1" }))
{ %>
<%= Html.Action("Create")%>
<% } %>
</div>
In this solutions data from from View Create not post to database. In this solutions data posted to database
<div id="Div1">
<%= Html.Action("Create")%>
</div>
View "Create" is strongly typed view.
Why is this happening ie why the first solution does not work?