zoukankan      html  css  js  c++  java
  • 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所示。

  • 相关阅读:
    bzoj2467 [中山市选2010]生成树
    hdu4489 The King’s Ups and Downs
    hdu4489 The King’s Ups and Downs
    Tyvj1014(区间dp)
    Tyvj1014(区间dp)
    Tyvj1013
    Tyvj1013
    Tyvj1009
    22.引用指针
    21.引用指针
  • 原文地址:https://www.cnblogs.com/meetyy/p/4009389.html
Copyright © 2011-2022 走看看