.Net MVC删除图片
还在学校,菜鸟级别,接触到的只是
/// <summary> /// 根据imageID删除图片 /// </summary> /// <returns></returns> public int deleteImage(image im) { return new InfoService().deleteImage(im); }
DAL = > BLL => UI
/// <summary> /// 根据ImgID删除图片 /// </summary> /// <param name="imgID"></param> /// <returns></returns> public JsonResult delImg(string imgID) { img.imageID = Convert.ToInt32(imgID); int result = im.deleteImage(img); JsonResult json = new JsonResult(); if (result > 0) { json.Data = new { data = "Success" }; json.JsonRequestBehavior = JsonRequestBehavior.AllowGet; } else { json.Data = new { data = "Failed" }; json.JsonRequestBehavior = JsonRequestBehavior.AllowGet; } return json; }
$(".btnDel").click(function () { var imgID=$(this).data('del'); //询问框 layer.confirm('您确定删除吗?', { btn: ['确定', '取消'] //按钮 }, function () { $.ajax({ url: '/Info/delImg', type: "get", data: { imgID:imgID }, success: function (data) { if (data.data == "Success") { layer.msg('删除成功', { icon: 1 }); } }, error: function (data) { layer.msg('删除失败', { icon: 2 }); } }) //layer.msg('删除按钮被点击', { icon: 1 }); //去删除 }, function () { layer.msg('取消按钮被点击', { time: 20000, //20s后自动关闭 btn: ['明白了', '知道了'] }); }); });