单击 Kendo UI 按钮调用服务器端 MVC 操作 [英] Call a server side MVC action on the click of a Kendo UI button

查看:20
本文介绍了单击 Kendo UI 按钮调用服务器端 MVC 操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚下载了 ASP.NET MVC 的 Kendo UI 包装器 v2013.3.1119.440 的试用版.我在这个版本中看到了一个新的 Kendo.Mvc.UI.Fluent.ButtonBuilder 包装器,它不是我 20 天前在另一台 PC 上下载的版本.

I just download a trial version of v2013.3.1119.440 of the Kendo UI wrappers for ASP.NET MVC. I see a new Kendo.Mvc.UI.Fluent.ButtonBuilder wrapper in this version that wasn't in the version I had downloaded just 20 days ago on another PC.

所述包装器代表一个按钮.

The said wrapper represents a button.

我看不到直接将这个 Kendo.Mvc.UI.Fluent.ButtonBuilder 包装器与服务器端 MVC 操作连接起来的方法.我该怎么做?

I can't see a way to directly wire this Kendo.Mvc.UI.Fluent.ButtonBuilder wrapper with a server side MVC action. How do I do that?

我确实在 ButtonBuilder 类上看到了 Events 方法,它接受 Action 事件.在 ButtonEventBuilder 中,我看到另一个名为 Click 的方法,它有两个重载,但都用于连接按钮的客户端事件处理程序.

I do see the Events method on the ButtonBuilder class, which accepts a Action<ButtonEventBuilder> events. In the ButtonEventBuilder, I see another method called Click, which has two overloads, but both are for wiring client side event handlers of the button.

我没有看到通过单击按钮直接连接服务器端回调/回发的方法.

I don't see a way to directly wire up a server side call-back/post-back with the button click.

我错过了什么吗?唯一的方法是手动触发服务器端回发或从 JavaScript 函数回调吗?

Am I missing something? Is the only way to do it the manual way of firing the server side post back or call back from a JavaScript function?

推荐答案

Button 是最新版本的 Kendo UI(上周)中的新增功能.它不直接支持您正在寻找的内容,但可以像这样完成类似的事情:

The Button is new in the latest release of Kendo UI (last week). It doesn't directly support what you're looking for, but something similar could be accomplished like this:

@(Html.Kendo().Button()
    .Name("textButton")
    .Content("Text button")
    .HtmlAttributes( new {type = "button"} )
    .Events(ev => ev.Click("onClick")))

然后一个类似这样的JS函数:

Then a JS function similar to this:

function onClick(){
    $.ajax({
        url: '/controller/action'
        data: { // data here }
    }).done(function(result){
        // do something with the result
    }).fail(function() { // handle failure });
}

更多信息可以在他们的演示站点找到:http://demos.kendoui.com/web/button/events.html

More info can be found in their demo site: http://demos.kendoui.com/web/button/events.html

这篇关于单击 Kendo UI 按钮调用服务器端 MVC 操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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