In my project, I have a parent and a child, and then the child as well has children so you can think about it as a three stages hierarchy. when I am in the third child (let me call it as a grandchild) I use an asp tag to go back to the second child view. the thing is what I am using right now gets me back to the whole index of the second child from all the parents, what I want is to get only the view of the second child of the parent I originally selected, not all children of all parents (Index). I hope this is not too complicated.
<a asp-controller="Surveys" asp-action="Index" class="btn btn-link">Back to Surveys</a>
i tried using asp-route-id="ViewData['ProjectId']" but still didn't work.
Try to pass project id using Model, something similar to this
@model Speaker
<a asp-controller="Speaker"
asp-action="Detail"
asp-route-id="@Model.SpeakerId">SpeakerId: @Model.SpeakerId</a>
HTML Output:
<a href="/Speaker/Detail/12">SpeakerId: 12</a>
If you are pass id with separate name ( not default Id)
<a asp-controller="Speaker"
asp-action="Detail"
asp-route-speakerid="@Model.SpeakerId">SpeakerId: @Model.SpeakerId</a>
HTML Output:
<a href="/Speaker/Detail?speakerid=12">SpeakerId: 12</a>
Consider checking detailed article here
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.