![](/img/trans.png)
[英]How to use Url.Action to get to the controller and also generate the url
[英]how to pass parameter with @url.action to controller
我有以下代碼片段我想用@ url.action傳遞data-id =“0”,我該怎么做
<a class="v-patient pointer" data-id="0" href="@Url.Action("View1", "Task")">View Patient</a></td>
我的任務控制器
public ActionResult View1(string id)
{
return View();
}
如果是ActionLink
你會這樣做:
@Html.ActionLink("View1", "Task", new {id=0}, null);
所以在你的情況下,使用Url.Action()
將是:
href="@Url.Action("View1", "Task", new {id=0})"
你的樣本中有哪些:
<a class="v-patient pointer" data-id="0" href="@Url.Action("View1", "Task", new {id=0})">View Patient</a></td>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.