Click here to Skip to main content
15,885,914 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am newer to C# and visual studio. So i want to know that how to call a controller's method from a view by clicking a hyper link. please hep me. Thank you.
Posted

XML
Hope it will help you,

<a href="/Home/Test" >sampleclick</a>

in the above url Home is a ControllerName and Test is a MethodName that i am calling
 
Share this answer
 
Comments
Sinisa Hajnal 18-May-15 2:29am    
Note: the class should be called HomeController, not just Home.
Use Html.ActionLink

http://www.w3schools.com/aspnet/mvc_htmlhelpers.asp[^]

If you are looking to do this after the page has loaded via ajax then use Ajax.ActionLink

Update a div Content using Ajax.ActionLink[^]

Or if you want to do the above using jQuery then google "call mvc action via jquery" for lots of examples of that.
 
Share this answer
 
v2

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