This is a migrated thread and some comments may be shown as answers.

Create, Update, Destroy Not Calling WebMethods

1 Answer 117 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Joel
Top achievements
Rank 2
Joel asked on 19 Sep 2013, 10:25 PM
I am using the following in my dataSource:

            transport: {
                read: {
                    contentType: "application/json; charset=utf-8",
                    url: "DepartmentHome.aspx/GetMembers",
                    dataType: "json"
                },
                create: {
                    url: "DepartmentHome.aspx/CreateMember",
                    type: "POST"
                },
                update: {
                    url: "DepartmentHome.aspx/EditMember",
                    type: "POST"
                },
                destroy: {
                    url: "DepartmentHome.aspx/DeleteMember",
                    type: "POST"
                }                
            },

and in my code behind I have defined the WebMethods as such:

        [WebMethod]
        public static void CreateMember()
        {
            File.WriteAllText(@"C:\testing.txt", "This is a create.");
        }

        [WebMethod]
        public static void EditMember()
        {
            File.WriteAllText(@"C:\testing.txt", "This is an update.");
        }

        [WebMethod]
        public static void DeleteMember()
        {
            File.WriteAllText(@"C:\testing.txt", "This is a delete.");
        }

When I create, edit, or delete a record it looks as if it has done it in the grid but it never calls the associated WebMethod.
I do see in firebug that it sends:
POST CreateMember
POST EditMember
POST DeleteMember

When I click on the associated buttons the POST data contains the parameters for that row:
FirstName: John
Id: 1
LastName: Smith

The Response back from the POST is just all the html from the page DepartmentHome.aspx.

I am using a WebMethod for read and that is working perfectly.  I don't know what the difference would be?

I have attached the complete source code.

Any help would be greatly appreciated.






1 Answer, 1 is accepted

Sort by
0
Rosen
Telerik team
answered on 23 Sep 2013, 02:42 PM
Hello Joel,

I suspect that the issue you have described is caused by missing contentType option of the transport's Update/Create and Destroy operations configuration. You can find a  runnable example of CRUD operations with Web methods here.

Regards,
Rosen
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
Joel
Top achievements
Rank 2
Answers by
Rosen
Telerik team
Share this question
or