单击Kendo UI按钮调用服务器端MVC操作 [英] Call a server side MVC action on the click of a Kendo UI button
问题描述
我刚刚下载了针对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.
我看不到直接用服务器端MVC动作连接此Kendo.Mvc.UI.Fluent.ButtonBuilder
包装器的方法.我该怎么办?
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>
事件.在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屋!