1、刪除
<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<dynamic>" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Index</title>
<script type="text/javascript">
function del(id) {
if (confirm("Are you sure?")) {
window.location = "default/del/1";
}
}
</script>
</head>
<body>
<div>
<a href="javascript:del(1)">sc</a>
</div>
</body>
</html>
再添加新的控制器,但不需要生成頁面了。直接寫操作方法
public ActionResult del(int id)
{
//Response.Write("<script>alert('刪除"+id+"!')</script>");
return Content("<script>alert('刪除" + id + "!')</script>");
}