MVC中的RazerPage中使用超链接的三种方式

@{
    ViewData["Title"] = "Home Page";
   // Layout = null;//不使用公共布局
}

@model List<Student>

    <h1 style="color:aqua">@ViewBag.t2</h1>
    <h1 style="color:red">@ViewData["t1"]</h1>  
    <h1 style="color:yellow">@TempData["t3"] </h1> 

<div class="text-center">
  <table>
      <thead>
          <tr>
              <th>事件:</th>
              <th>学号:</th>
              <th>姓名:</th>
          </tr>
      </thead>

      <tbody>
            @foreach(var item  in Model)
            {
                <tr>
                  @*  <td><a href="/Home/Detail/@item.Id">查看详情</a> </td>*@
                    <td>@Html.ActionLink("查看详情","Detail","Home",new{Id=item.Id})</td>
                   @* <td><a asp-controller="Home" asp-action="Detail" asp-route-id="@item.Id">查看详情</a></td>*@
                    <td>@item.Id</td>
                    <td>@item.Name</td>

                </tr>
            }

      </tbody>

  </table>
</div>

posted @ 2022-08-13 14:06  码农阿亮  阅读(18)  评论(0)    收藏  举报