kavayo
جمعه 13 دی 1392, 11:00 صبح
من در برنامه ام از کنترل های kendo استفاده میکنم و مثلا کل مشتریان را در یک grid نمایش میدهم و با انتخاب هر سطر مشخصات انها در پنجره ای که طراحی کرده ام و تمامی مشخصات داخل یک ajax.beginform نمایش داده میشود حال میخواهم پس از ویرایش مشخصات یک مشتری در این پنجره صفحه مرورگر refresh نشود با اینکه من از ajax.beginform نیز استفاده کرده ام اما باز هم مرورگر refresh میشود در حالی که من میخواهم فقط grid بروزرسانی شود و ان هم به صورت ajax ای .حال من چگونه میتوانم این کار را انجام دهم؟
@using (Ajax.BeginForm("TestView", "Home", Model, new AjaxOptions { UpdateTargetId = "myform", OnSuccess = "alert('succseefully')", HttpMethod = "POST", InsertionMode = InsertionMode.Replace, LoadingElementId = "Progress" }))
{
@Html.AntiForgeryToken()
@Html.ValidationSummary(true)
<fieldset id="myform">
<legend>ویرایش و مشاهده مشتری ها</legend>
<fieldset/>}
[HttpPost]
public ActionResult TestView([Bind(Exclude = "CustomerAdress")]CustomerModel test, FormCollection collection) //CustomerAdress not update
{
// string error = null;
if (ModelState.IsValid)
{
var machine = new MachineEntities();
var customeredit = machine.Machine_Customer.Where(c => c.CustomerID ==test.CustomerID).Select(c => c);
if (TryUpdateModel(customeredit.FirstOrDefault()))
{
machine.SaveChanges();
return RedirectToAction("_tab3");
}
// machine.Entry(cust).State = EntityState.Modified;
// machine.SaveChanges();
return View("Index");
}
else
{
// ModelState.AddModelError("Customername", "مقدار مورد نیاز است");
return View("TestView",GetByID(test.CustomerID.ToString()));
}
}
@using (Ajax.BeginForm("TestView", "Home", Model, new AjaxOptions { UpdateTargetId = "myform", OnSuccess = "alert('succseefully')", HttpMethod = "POST", InsertionMode = InsertionMode.Replace, LoadingElementId = "Progress" }))
{
@Html.AntiForgeryToken()
@Html.ValidationSummary(true)
<fieldset id="myform">
<legend>ویرایش و مشاهده مشتری ها</legend>
<fieldset/>}
[HttpPost]
public ActionResult TestView([Bind(Exclude = "CustomerAdress")]CustomerModel test, FormCollection collection) //CustomerAdress not update
{
// string error = null;
if (ModelState.IsValid)
{
var machine = new MachineEntities();
var customeredit = machine.Machine_Customer.Where(c => c.CustomerID ==test.CustomerID).Select(c => c);
if (TryUpdateModel(customeredit.FirstOrDefault()))
{
machine.SaveChanges();
return RedirectToAction("_tab3");
}
// machine.Entry(cust).State = EntityState.Modified;
// machine.SaveChanges();
return View("Index");
}
else
{
// ModelState.AddModelError("Customername", "مقدار مورد نیاز است");
return View("TestView",GetByID(test.CustomerID.ToString()));
}
}