如何在锚标记中调用控制器操作。 [英] How to call a controller action in anchor tag.

查看:88
本文介绍了如何在锚标记中调用控制器操作。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在锚标记中调用控制器动作。



我试过这些代码,但没有工作



< 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆