如何在锚标记中调用控制器操作。 [英] How to call a controller action in anchor tag.
问题描述
如何在锚标记中调用控制器动作。
我试过这些代码,但没有工作
< a href =/ BPGController / AddToContact>添加到联系人< / a>< br />
< a href =@ Url.Action( AddToContact,BPGController)>添加到联系人< / a>< br />
< a href =#onclick =location.href ='@ Url .Action(AddToContact)'>添加到联系人< / a>< br />
@ Html.ActionLink(添加到联系人,AddToContact,BPGController )
他们都不工作。我是MVC的初学者。
How to call a controller action in anchor tag.
I have tried this these code, but not working
<a href="/BPGController/AddToContact">Add to Contact</a><br />
<a href="@Url.Action("AddToContact", "BPGController")">Add to Contact</a><br />
<a href="#" onclick="location.href='@Url.Action("AddToContact")'">Add to Contact</a><br />
@Html.ActionLink("Add to Contact", "AddToContact", "BPGController")
None of them working. I am beginner in MVC.
推荐答案
在第二次尝试中,使用BPG代替BPGController。
In your 2nd try, Use BPG in place of BPGController.
这篇关于如何在锚标记中调用控制器操作。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!