My insert button inside Ajax.beginform().
<div id="createDescriptors">
@using (Ajax.BeginForm(
"InsertDescriptors",
new { id = Model.CitationID},
new AjaxOptions()
{
UpdateTargetId = "createDescriptors",
HttpMethod = "post",
}
) )
{
<div class="grid">
<div class="row gridRow">
<div class="span1">
<input type="image" id="btnInsertDes" src="~/Content/Icons/Add.png">
Insert
</div>
<div class="span1">
<input type="image" id="btnEditDes" src="~/Content/Icons/Edit.png" >
Edit
</div>
<div class="span1">
<input type="image" id="btnDeleteDes" src="~/Content/Icons/Delete.png">
Delete
</div>
<div class="span1">
<input type="image" id="btnSaveDes" src="~/Content/Icons/Save.png" >
Save
</div>
</div>
</div>
and here is my controller Action method:
public JsonResult InsertDescriptors([DataSourceRequest] DataSourceRequest request, CitationDescriptor citationDescriptor, int id)
{
citationDescriptor.CitationID = id;
citationDescriptor.DBProviderID = 1;
if( citationDescriptor != null && (ModelState.IsValid))
{
Db.Descriptors.Add(citationDescriptor);
Db.SaveChanges();
}
return Json(new[] { citationDescriptor }.ToDataSourceResult(request, ModelState), "application/json");
}
Thanks for your help!
VANDANA
<div id="createDescriptors">
@using (Ajax.BeginForm(
"InsertDescriptors",
new { id = Model.CitationID},
new AjaxOptions()
{
UpdateTargetId = "createDescriptors",
HttpMethod = "post",
}
) )
{
<div class="grid">
<div class="row gridRow">
<div class="span1">
<input type="image" id="btnInsertDes" src="~/Content/Icons/Add.png">
Insert
</div>
<div class="span1">
<input type="image" id="btnEditDes" src="~/Content/Icons/Edit.png" >
Edit
</div>
<div class="span1">
<input type="image" id="btnDeleteDes" src="~/Content/Icons/Delete.png">
Delete
</div>
<div class="span1">
<input type="image" id="btnSaveDes" src="~/Content/Icons/Save.png" >
Save
</div>
</div>
</div>
and here is my controller Action method:
public JsonResult InsertDescriptors([DataSourceRequest] DataSourceRequest request, CitationDescriptor citationDescriptor, int id)
{
citationDescriptor.CitationID = id;
citationDescriptor.DBProviderID = 1;
if( citationDescriptor != null && (ModelState.IsValid))
{
Db.Descriptors.Add(citationDescriptor);
Db.SaveChanges();
}
return Json(new[] { citationDescriptor }.ToDataSourceResult(request, ModelState), "application/json");
}
Thanks for your help!
VANDANA