![](/img/trans.png)
[英]How to pass Ajax from post success data to another View in asp.net MVC
[英]ASP.NET MVC- How to pass data to another view
在视图中:
<table>
@foreach(String key in map.Keys)
{
<tr>
<td>
<a href="@Url.Action("page2", "page1")"> @key </a>
<td>
<tr>
}
<table>
如何将键的值传递给 page2 并在 page2 中检索它?
您可以使用Url.Action
的重载向查询字符串添加值:
Url.Action("page2", "page1", new { key = key })
这会将key
的值添加到 URL 查询字符串中,由键"key"
表示。
除了使用 Url.Action 传递值外,您还可以使用 Html.ActionLink。
@Html.ActionLink("some text here", "actionName", "controllerName", new { id = "1" }, null)
它为您提供如下链接。
<a href="/controllerName/actionName/1">some text here</a>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.