How to save editor data to code behind in ASP.NET C#?
How to save editor data to code behind in ASP.NET C#?
![lakshmanankarthi](https://secure.gravatar.com/avatar/e2eed2718a62bf7a1a0f8270348e66e3/?default=https%3A%2F%2Fvanillicon.com%2Fe2eed2718a62bf7a1a0f8270348e66e3_200.png&rating=g&size=120)
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.
This discussion has been closed.
Answers
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
Thanks for as usual helping allan
.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: :disappointed:](https://datatables.net/forums/resources/emoji/disappointed.png)
Have you tried moving the code into a separate ASMX page?
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