Posting data using AJAX
Posted
by ognjenb
on Stack Overflow
See other posts from Stack Overflow
or by ognjenb
Published on 2010-05-13T16:31:31Z
Indexed on
2010/05/13
16:34 UTC
Read the original article
Hit count: 275
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?
© Stack Overflow or respective owner