Ajax.BeginForm beforeSubmit事件 [英] Ajax.BeginForm beforeSubmit event

查看:195
本文介绍了Ajax.BeginForm beforeSubmit事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在MVC中,有没有办法使用Ajax.BeginForm时触发一个事件onBeforeSubmit?我想,以验证客户端上的一些数据,并给用户适当的反馈。

In MVC, is there a way to fire an onBeforeSubmit event when using Ajax.BeginForm? I'd like to validate some data on the client side and give proper feedback to the user.

推荐答案

OnBegin 就是你要找什么:

using (Ajax.BeginForm("Action", "Controller", 
new AjaxOptions() {
OnBegin = "alert('Replace with validation logic.')"
}))

更新

事情是这样的:

   function onSubmitFeedbackBegin(context) {
        if (uploading > 0) {
            return false;
        }
    }

这篇关于Ajax.BeginForm beforeSubmit事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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