Search code examples
ajaxpagemethods

Can you use AJAX page methods to make non-static function calls?


Javascript:

PageMethods.DragEventToEvent(event.text(), event.parent().parent().text(), cell.parent().text(),   OnSucceeded, OnFailed);

C# Function:

    [WebMethod]
    public static void DragEventToEvent(string evt, string startCell, string endCell) {
       //Blahblah
    }

This "works", but it's a static call. I need a non-static call here. Can it be done with page methods?


Solution

  • No you cant use non-static function calls with PageMethods.

    Use System.Web.UI.ICallbackEventHandler instead.

    Implementing Client Callbacks Programmatically Without Postbacks in ASP.NET Web Pages

    Example 1:

    Asynchronous client script callbacks

    Example 2:

    Using ICALLBACKEventHandler in ASP.NET

    GL HF ;)