Click here to Skip to main content
15,891,473 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.
Posted
Updated 25-Nov-19 8:31am

In your 2nd try, Use BPG in place of BPGController.
 
Share this answer
 
HTML
<a href="<?php echo base_url('BPGController/AddToContact')?>"></a>
 
Share this answer
 
v2
Comments
OriginalGriff 11-Nov-19 2:41am    
While I applaud your urge to help people, it's a good idea to stick to new questions, rather than 5 year old ones. After that amount of time, it's unlikely that the original poster is at all interested in the problem any more! And you have to be careful as well - your solution appeared to be blank because you didn't enclose it in pre tags (use the code> widget when entering it) so it looks even more like abusive behaviour.
Answering old questions can be seen as rep-point hunting, which is a form of site abuse. The more trigger happy amongst us will start the process of banning you from the site if you aren't careful. Stick to new questions and you'll be fine.

I've edited it so it now appears less like abuse, and I'll get the banning procedure stopped - but please, be more careful next time!
Richard Deeming 11-Nov-19 4:26am    
In addition to Griff's comments, the original question appears to be about ASP.NET MVC; your solution is for PHP.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900