.net core mvc初级教程(六)

一、创建movie的视图
二、对cinema、movie视图添加‘添加信息’的操作

一、创建movie的视图

在views文件夹下添加Movie文件夹,在这个文件夹下添加Index.cshtml视图,为什么添加Index.cshtml这个名字的视图,可以看看我们写的MovieController控制器

@using DemoCoreStudy.Models
@model IEnumerable<Movie>

<div class="container">
    <div class="row">
        <table class="table">
            <thead class="thead-dark">
                <tr>
                    <th scope="col">Id</th>
                    <th scope="col">Name</th>
                    <th scope="col">Staring</th>
                    <th scope="col">ReleseDate</th>
                     <th></th>
                </tr>
            </thead>
            <tbody>
                @Html.DisplayForModel()
            </tbody>
        </table>
    </div>
</div>

然后再Movie文件夹下添加DispalyTemplates文件夹,其中添加Movie.cshtml视图

@model DemoCoreStudy.Models.Movie

<tr>
    <th scope="col">@Model.Id</th>
    <td>@Model.Name</td>
    <td>@Model.Starring</td>
    <td>@Model.ReleseDate</td>
    <td asp-action="Edit" asp-route-movieId="@Model.Id">编辑</td>
</tr>

接下来回到MovieController控制器添加Edit方法

public IActionResult Edit(int movieId)
        {
            return RedirectToAction("Index");
        }
``
`然后我们回到Cinema.cshtml,写下一个跳转链接,点一下电影名可以跳转到对应的的电影界面

@model DemoCoreStudy.Models.Cinema

@Model.Id @Model.Name @Model.Location @Model.Capacity 编辑 `
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值