如何从mvc3中的视图调用控制器方法 [英] how to call a controller method from view in mvc3

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

问题描述

我是C#和visual studio的新手。所以我想知道如何通过单击超链接从视图中调用控制器的方法。请帮我。谢谢。

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.

推荐答案

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


使用Html.ActionLink



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



如果你想做什么他的页面通过ajax加载后然后使用Ajax.ActionLink



使用Ajax.ActionLink更新div内容 [ ^ ]



或者如果你想这样做上面使用jQuery然后google通过jquery调用mvc动作获取大量的例子。
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.


这篇关于如何从mvc3中的视图调用控制器方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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