如何传递参数@ url.action到控制器 [英] how to pass parameter with @url.action to controller
本文介绍了如何传递参数@ url.action到控制器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下代码片段,我想传递data-id =0与我的@ url.action,我该怎么做
i have following code snippet i want to pass data-id="0" with my @url.action , how can i do this
<a class="v-patient pointer" data-id="0" href="@Url.Action("View1", "Task")">View Patient</a></td>
我的任务控制器
public ActionResult View1(string id)
{
return View();
}
推荐答案
c $ c> ActionLink 您将这样做:
If is was an ActionLink
you would do this:
@Html.ActionLink("View1", "Task", new {id=0}, null);
所以在你的情况下,使用 Url.Action()
它会是:
So in your case, using Url.Action()
it would be:
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>
这篇关于如何传递参数@ url.action到控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文