将ASP.NET PageMethods与JQuery DataTables一起使用? [英] Using ASP.NET PageMethods with JQuery DataTables?

查看:79
本文介绍了将ASP.NET PageMethods与JQuery DataTables一起使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于初学者来说,我是ASP.NET Ajax的新手,并且在长时间中断之后才重新进入JQuery,所以请原谅这个问题的任何愚蠢之处:)

For starters, I'm new to ASP.NET Ajax stuff, and only getting back into JQuery after a long hiatus, so excuse any stupid sounding parts of this question :)

我想在ASP.NET页面中将DataTable插件用于JQuery.另外,我想进行服务器端分页.似乎要这样做,我将不得不创建一个Web服务并将所述服务的URL提供给DataTable的"sAjaxSource"属性.

I would like to use the DataTable plug-in for JQuery in my ASP.NET page. Additionally, I'd like to do server-side pagination. It seems like in order to do that, I would have to create a web service and provide the url of said service to the "sAjaxSource" property of the DataTable.

我现在正在发现"PageMethods",它看起来类似于Web服务,但直接写在特定页面上.如果DataTable插件和ASP.NET"PageMethods"可以很好地协同工作,那将是很好的选择,但是我不确定这将如何工作.

I'm just now discovering "PageMethods", which appear to be similar to a web service but are written directly on a specific page. It would be nice if the DataTable plug-in and the ASP.NET "PageMethods" would work nicely together, but I'm not sure how that would work.

所以我想我想知道用于sAjaxSource的url是否可以以指向页面本身并表示在此页面上使用此PageMethod"的方式来声明.还是有一种内置的方式来手动构造ajax调用/响应,以便我可以直接使用类似"PageMethods.GetTable()"的方法?希望这是有道理的,但是如果不清楚,请告诉我.预先感谢!

So I guess I'm wondering if the url used for sAjaxSource can be stated in a way that points to the page itself and means "use this PageMethod on this page". Or is there a built in way to manually construct the ajax call/response so I could use something like "PageMethods.GetTable()" directly? Hopefully this makes sense, but please let me know if it is unclear. Thanks in advance!

推荐答案

您可以像使用Web服务一样,在页面上调用Page方法,

You can call a Page Method on a page in the same way you would a web service, like this

MyPage.aspx/WebMethodName

只需确保您的方法为static并添加了[ScriptMethod]属性即可.

Just make sure your method is static and has the [ScriptMethod] attribute added.

这篇关于将ASP.NET PageMethods与JQuery DataTables一起使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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