How to save editor data to code behind in ASP.NET C#?

How to save editor data to code behind in ASP.NET C#?

lakshmanankarthilakshmanankarthi Posts: 2Questions: 1Answers: 0
edited July 2018 in Free community support

My Client side InlineEdit.aspx

 $(document).ready(function () {
        editor = new $.fn.dataTable.Editor({
            ajax: "InlineEdit.aspx/Data",
            table: "#example",
            "idSrc": "POS",
            fields: [{
                label: "POS",
                name: "POS"
            },
            {
                label: "Type",
                name: "Type"
            }
            ]
        });
        $('#example').on('click', 'tbody td:not(:first-child)', function (e) {
            editor.inline(this);
        });
        $('#example').DataTable(
        {
            "columnDefs": [
                { "width": "5%", "targets": [0] }
            ],
            "language":
                {
                    "processing": "<div class='overlay custom-loader-background'><i class='fa fa-cog fa-spin custom-loader-color'></i></div>"
                },
            //"processing": true,
            //"serverSide": true,
            "ajax":
                {
                    "url": "InlineEdit.aspx/GetData",
                    "contentType": "application/json",
                    "type": "GET",
                    "dataType": "JSON",
                    "data": function (d) {                     
                        return d;
                    },
                    "dataSrc": function (json) {                   
                        json = $.parseJSON(json.d);               
                        var return_data = json;                      
                        return return_data;
                    }
                },
            "columns": [
                {
                    "data": null,
                    "defaultContent": "1",
                    "className": "select-checkbox",
                    "orderable": "false"
                },
                        { "data": "POS" },
                        { "data": "Type" }
                     ],
        });
    });

Code behind InlineEdit.aspx.cs

[WebMethod]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json, UseHttpGet = true)]
        public static string Test()
        {
            try
            {
                return null;
            }
            catch (Exception)
            {
                throw;
            }
        }

I have checked test method previously but not work.So i decide change my code like below

 [WebMethod(Description = "Server Side DataTables support", EnableSession = true)]
        [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
        public static void Data([FromBody]object parameters)
        {
            string req = "";
            SendResponse(HttpContext.Current.Response, req);
        }

This also not work .Not hitting breakpoint also.
Please help us?

Edited by Allan - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

Answers

  • allanallan Posts: 63,331Questions: 1Answers: 10,436 Site admin

    Hi,

    It sounds like a routing issue - if InlineEdit.aspx/Data isn't hitting your method, then for some reason it isn't being routed there. I'm not certain why that would be without being able to see your routing configuration.

    That said, it would be worth reading over the aspx part of the Editor documentation as that details how you can use an aspx codebehind page with Editor.

    Allan

  • lakshmanankarthilakshmanankarthi Posts: 2Questions: 1Answers: 0

    Thanks for as usual helping allan :wink: .In aspx i believe no route config.and one more thing same url i am used line 32.that is working fine.Get the data from DB and loaded to front end.

    I have tried inline editing everything working except updated data not hit code behind :disappointed:

  • Bindrid2Bindrid2 Posts: 79Questions: 4Answers: 12

    Have you tried moving the code into a separate ASMX page?

  • allanallan Posts: 63,331Questions: 1Answers: 10,436 Site admin

    So does it Ajax load the data correctly from the code behind? It is just the update that isn't?

    Is it on the web - can you give me a link to it please?

    Allan

This discussion has been closed.