// GET: Student public ActionResult Index() { BlogsDB db = new BlogsDB(); db.Student.Add(new Models.Students() { Name = "mas", Age = 28 }); db.SaveChanges(); var list = db.Student.ToList(); return(View(list)); }
protected void Page_Load(object sender, EventArgs e) { if (Page.IsPostBack) { string blog_id = Request["blog_id"]; BlogsDB db = new BlogsDB(); if (blog_id != "") { db.Delete(blog_id); Response.Redirect("Index.aspx"); } else { Response.Write("blog_id不能为空"); Response.Redirect("Delete.aspx"); } } }
protected void Page_Load(object sender, EventArgs e) { if (Page.IsPostBack) { string blog_title = Request["blog_title"]; string blog_body = Request["editor"]; Blogs b = new Blogs(); b.Blog_title = blog_title; b.Blog_body = blog_body; if (Session["user"] != null) { b.User_id = Session["user"].ToString(); BlogsDB db = new BlogsDB(); db.Write(b); } else { Response.Write("出错"); } } }
protected void Page_Load(object sender, EventArgs e) { if (Page.IsPostBack) { string keyword = Request["keyword"]; BlogsDB db = new BlogsDB(); List <Blogs> u = new List <Blogs>(); if (keyword != "") { if (db.Search(keyword).Count > 0) { Session["keyword"] = keyword; Response.Redirect("Result.aspx"); } } else { Response.Write("用户名密码不能为空"); } } }