ASP.NET MVC+LINQ开发图书销售站点(7)图书分类管理
时间:2008-04-01 02:32:37 来源:cnblogsfans.cnblogs.com 作者:王德水 【背景色
】
2、添加目录
a. 现在我们来实现新建的功能,修改CategoryController的Add的行为,新建一个AddSaved的行为保存新建的目录,并导航到List视图
//Category/Add
public void Add()
{
RenderView("AddCategory");
}
public void AddSaved()
{
Category newCategory = new Category { CategoryName = Request.Form["CategoryName"] };
db.AddCategory(newCategory);
RedirectToAction(new RouteValueDictionary(new { controller = "Category", action = "List" }));
}
public void Add()
{
RenderView("AddCategory");
}
public void AddSaved()
{
Category newCategory = new Category { CategoryName = Request.Form["CategoryName"] };
db.AddCategory(newCategory);
RedirectToAction(new RouteValueDictionary(new { controller = "Category", action = "List" }));
}
b. 我们需要在view\category\下建一个AddCategory.aspx(MVC view content page)来新建一个视图

c. 最终效果


文章评论
共有 0位网翼网友发表了评论 查看完整内容