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

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所示。

 

posted @ 2014-10-07 15:24  liesl  阅读(316)  评论(2编辑  收藏  举报