删除记录的确认框jquery flexigid c#
我通过从c#controller返回json格式的记录来填充jquery flexigrid。然而,我面临着一点小问题。我正在添加herf列以删除特定记录。它的作品很好,但我无法找到方法,以确认它删除之前。下面是我的c代码,它将记录返回到flexigrid C#控制器代码段删除记录的确认框jquery flexigid c#,c#,jquery,asp.net-mvc,razor,flexigrid,C#,Jquery,Asp.net Mvc,Razor,Flexigrid,我通过从c#controller返回json格式的记录来填充jquery flexigrid。然而,我面临着一点小问题。我正在添加herf列以删除特定记录。它的作品很好,但我无法找到方法,以确认它删除之前。下面是我的c代码,它将记录返回到flexigrid C#控制器代码段 private JsonResult CreateFlexiJson(IEnumerable<user> items, int page, int total) { var Cur
private JsonResult CreateFlexiJson(IEnumerable<user> items, int page, int total)
{
var CurentsessionUser = Session["sessionUserId"].ToString();
List<Object> rows = new List<Object>();
foreach (var item in items)
{
rows.Add(new
{
id = item.id,
cell = new string[] {
item.msisdn,
item.pin,
item.subtype,
CurentsessionUser =="csagent"?"":String.Format("<a href=" + "'" + "ChangePin?subno=" + item.msisdn + "'" + ">Change Pin</a>"),
CurentsessionUser =="csagent"?"":String.Format("<a href=" + "'" + "Delete?subno=" + item.msisdn + "'" + ">Delete</a>")
}
});
}
var result = new { page = page, total = total, rows = rows };
return Json(result);
}
public ActionResult Delete(string subno)
{
try
{
wmas_subsEntities entitymodel = new wmas_subsEntities();
var customer = from p in entitymodel.users where p.msisdn == subno select p;
if (customer.ToList().Count > 0)
{
entitymodel.users.Remove(customer.First());
entitymodel.SaveChanges();
}
//return Json("Successfully deleted the user registeration");
return View("Index");
}
catch (Exception ex)
{
throw ex;
}
}
在
CreateFlexiJson
操作中,在第行下方进行更改
CurentsessionUser =="csagent"?"":String.Format("<a href=" + "'" + "Delete?subno=" + item.msisdn + "'" + ">Delete</a>")
CurentsessionUser =="csagent"?"":String.Format("<a href=" + "'" + "Delete?subno=" + item.msisdn + "'" + ">Delete</a>")
CurentsessionUser =="csagent"?"":String.Format("<a href='javascript:void(0)' onclick='deleteSubscriber(\"" + item.msisdn + "\")'>Delete</a>")
function deleteSubscriber(subno) {
if (confirm("Are you sure to delete Subscriber (No. = " + subno + ")")) {
location.href = "Delete?subno=" + subno;
}
}