如何在Mvc 4中添加Ajax? [英] How Do I Add Ajax In Mvc 4 ?

查看:75
本文介绍了如何在Mvc 4中添加Ajax?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨开发者,



创建一个MVC4应用程序。我曾经在aspx页面中使用更新面板和脚本amanger添加ajax。但我不知道如何在MVC剃须刀中做到这一点。任何人都可以帮我这个吗?



我的要求是:

我有一个创建用户部分,当用户点击创建,创建用户进程应该异步进行。它应该添加用户而不重新加载。



我如何做这个aspx:

脚本管理器

更新面板

-----创建用户-----

关闭更新面板

 <   script     manager  >  
< updtepanel>
创建用户
< / update 面板 >



我如何在MVC中执行此操作:这就是我的问题。

解决方案

您可以使用jQuery的ajax方法,或者如果您想使用ajax框架来与MVC然后你是ajax帮手



http://www.dotnet-stuff.com/tutorials/aspnet-mvc/understanding-ajax-helpers-in-asp-net-mvc [<一个href =http://www.dotnet-stuff.com/tutorials/aspnet-mvc/understanding-ajax-helpers-in-asp-net-mvc\"target =_ blanktitle =New Window> ^ ]



要调用您的操作方法,请使用Ajax.ActionLink



HTTP s://msdn.microsoft.com/en-us/library/dd493106(v = vs.118).aspx [ ^ ]



创建一个ajax表单使用Ajax.BeginForm



https://msdn.microsoft.com/en-us/library/system.web.mvc.ajax.ajaxextensions.beginform(v = vs.118)。 aspx [ ^ ]



如果您使用谷歌,您应该找到有关如何使用这些内容的示例和教程。

Hi Developers,

Am creating one MVC4 application.I used to add ajax using update panel and script amanger in aspx pages. But i dont know how to do that in MVC razor. Can anyone help me on this?

My requirement is:
I have one create user section when the user clicks on create, create user process should happen asynchronously.It should add the user without reloading.

How do i do this aspx:
script manager
update panel
-----Create user-----
Close update panel

<script manager>
<updtepanel>
create user
</update panel>


How do i do this in MVC : thats my question.

解决方案

You can just use jQuery's ajax method, or if you want to use the ajax framework that comes with MVC then you ues the ajax helper

http://www.dotnet-stuff.com/tutorials/aspnet-mvc/understanding-ajax-helpers-in-asp-net-mvc[^]

To call your action methods use Ajax.ActionLink

https://msdn.microsoft.com/en-us/library/dd493106(v=vs.118).aspx[^]

To create an ajax form use Ajax.BeginForm

https://msdn.microsoft.com/en-us/library/system.web.mvc.ajax.ajaxextensions.beginform(v=vs.118).aspx[^]

If you google you should find examples and tutorials on how to use these.


这篇关于如何在Mvc 4中添加Ajax?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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