ASP.NET-ajax.BeginForm使用02
2016-03-24 09:10
495 查看
using就已经是引入了ajax了,其实是操作了js文件,所以这个是全局的,using 的{}没有必要把所有的东西都扩住
[/code]
[/code]
fk是后台已经定义的变量名,可以从前台把变量名传回去
注意
1.需要引用jquery.unobtrusive-ajax.js
2.需要在引用jquery后引用jquery.unobtrusive-ajax.js
3.config中需要有(这个MVC4,MVC5默认就是有的)
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
onBegin里面的函数是直接写就可以执行的
当然也可以写jquery的代码
来自为知笔记(Wiz)
@using (Ajax.BeginForm(
new AjaxOptions()
{
HttpMethod = "post",
Url = @Url.Action("ajax", "Home"),
InsertionMode = InsertionMode.Replace,
UpdateTargetId = "pid",
LoadingElementId = "loding",
LoadingElementDuration = 5000
}))
{
<input type="submit" value="点击返回ajax内容" />
}
[/code]
@using (Html.BeginForm("Person", "Home", new { fk = "this is fk test" }, FormMethod.Post))
[/code]
fk是后台已经定义的变量名,可以从前台把变量名传回去
注意
1.需要引用jquery.unobtrusive-ajax.js
2.需要在引用jquery后引用jquery.unobtrusive-ajax.js
3.config中需要有(这个MVC4,MVC5默认就是有的)
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
Confirm | 等效于javascript中的return confirm(msg),在点击该链接时先提示需要确认的信息。 |
HttpMethod | 指定使用Get或者是Post方式发送Http请求 |
InsertMode | 指定使用哪一种方式在指定的UpdateTargetId元素更新数据,可以有三种方式: "InsertAfter", "InsertBefore", or "Replace" 。默认为:Replace |
LoadingElementDuration | Loading元素显示的时间 |
LoadingElementId | 可以指定在Http请求期间显示的Loading元素 |
OnBegin | 在Http请求之前执行的javascript方法 |
OnComplete | 在Http请求结束时执行的方法 |
OnFailure | 在Http请求失败时执行的方法 |
OnSuccess | 在Http请求成功时执行的方法 |
UpdateTargetId | Http请求更新的页面元素 |
Url | Http请求的Url |
onBegin里面的函数是直接写就可以执行的
当然也可以写jquery的代码
来自为知笔记(Wiz)
相关文章推荐
- ASP.NET-ajax.acionlink使用
- ASP.NET-表单验证-DataAnnotations
- ASP.NET-Router配置中MapRoute的参数
- ASP.NET-Razor常用方法
- ASP.NET-RedirectToAction只能使用get方法
- ASP.NET Core 行军记 -----第一步(艰辛的 MVC Hello World)
- C# asp.net mvc 配置多个route 参数
- ASP.NET在底层类库中获取Session C#类中获取Session 原创
- 细谈asp.net如何处理应用程序-----c#菜鸟日记
- ASP.NET MVC系列:从Controller访问Model数据
- Asp.net 提供程序模型
- GRASP 职责分配原则[转]
- asp.net文件下载文件另存为
- asp.net在线QQ客服聊天
- 2016-AspNet-MVC教学-5-动态表格页面的基本测试-2
- ASPCMS标签教程
- 使用MiniProfiler给Asp.net MVC和Entity Framework号脉(附源码)
- ASP.NET会话丢失,Session超时配置
- asp.net 文件打包成压缩包
- 使用MiniProfiler调试ASP.NET MVC网站性能