您的位置:首页 > 其它

Week5(10月10日):国庆之后,让我们整装期待元旦吧

2014-10-07 15:24 197 查看
Part I:提问

===========================

1.要将“Hello, Admin",从控制器传递到视图,该如何操作?

(1)使用ViewData

(2)使用ViewBag

2.已知某学生类Student.cs,控制器中Index动作将学生传递给视图,请解释强类型传递的原理。

public ActionResult Index()
{
return View(db.Students.ToList());
}


@model IEnumerable<tempPractice.Models.Student>

@{
ViewBag.Title = "Index";
}

<h2>Index</h2>

<p>
@Html.ActionLink("Create New", "Create")
</p>
<table>
<tr>
<th>
@Html.DisplayNameFor(model => model.Name)
</th>
<th>
@Html.DisplayNameFor(model => model.StuNo)
</th>
<th>
@Html.DisplayNameFor(model => model.Phone)
</th>
<th></th>
</tr>

@foreach (var item in Model) {
<tr>
<td>
@Html.DisplayFor(modelItem => item.Name)
</td>
<td>
@Html.DisplayFor(modelItem => item.StuNo)
</td>
<td>
@Html.DisplayFor(modelItem => item.Phone)
</td>
<td>
@Html.ActionLink("Edit", "Edit", new { id=item.Id }) |
@Html.ActionLink("Details", "Details", new { id=item.Id }) |
@Html.ActionLink("Delete", "Delete", new { id=item.Id })
</td>
</tr>
}

</table>


Part II:Ch03 视图3

===========================

要点:

1.知识点3-5:使用强类型模板

2.知识点3-6:HTML辅助方法

3.动手吧>>:在自己的大作业网站中,实现留言功能。要求如http://192.168.55.163/TakeLearning所示。

参考资料见教程,演练3-1:留言管理系统的制作

该作业将在10月17日检查。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: