Datatable Editor to work with Asp.net webforms

Datatable Editor to work with Asp.net webforms

dashyferdashyfer Posts: 7Questions: 1Answers: 0

I've been trying to post a question here all day long, still not approved.

In case someone has an answer here is the link to the question

Replies

  • kthorngrenkthorngren Posts: 21,292Questions: 26Answers: 4,944

    You are getting this error:

    Error: DataTables warning: table id=VacationCalendarTableUsingEditorNet - Ajax error. For more information about this error, please see http://datatables.net/tn/7

    The place to start is with the troubleshooting steps provided in the URL: http://datatables.net/tn/7

    Let us know what you find using those steps.

    Kevin

  • dashyferdashyfer Posts: 7Questions: 1Answers: 0

    Hello... thanks for your answer
    i did the troubleshoot and what i found is that i get a double ajax request as a response post.
    this is what i get
    http://localhost:48849/MyProject/GetTableResultsUsingEditorNet/GetTableResultsUsingEditorNet
    instead of
    http://localhost:48849/MyProject/MyForm.aspx/GetTableResultsUsingEditorNet
    why is that?
    In my ajax option i only have a post call to get the datatable to load like in the Webforms/ ASPX example.
    What am i missing?

  • dashyferdashyfer Posts: 7Questions: 1Answers: 0

    Me again,
    I came to one conclusion and i might be wrong but i think Editor is not fit for asp.net webforms here is what i tried.

    in the Editor block i added:

    ajax: {
                        create: {
                            type: 'POST',
                            url: "<%= System.IO.Path.GetFileName(Request.Url.AbsolutePath) %>/CreateVacationCalendar"
                        },
                        edit: {
                            type: 'PUT',
                            url: "<%= System.IO.Path.GetFileName(Request.Url.AbsolutePath) %>/UpdateVacationCalendar"
                        },
                        remove: {
                            type: 'DELETE',
                            url: "<%= System.IO.Path.GetFileName(Request.Url.AbsolutePath) %>/DeleteVacationCalendar"
                        }
    

    in the Datatable block i changed the ajax call for a Get instead of a Post

    ajax: {
                        "url": "<%= System.IO.Path.GetFileName(Request.Url.AbsolutePath) %>/GetTableResultsUsingEditorNet",
                        "type": "GET",
                        "dataType": "json",
                        "contentType": "application/json; charset=utf-8"
                    },
    

    In the code behind(aspx.cs file) i did every method for those CRUD request and the only one working is the one to Get.

    [WebMethod]
    [HttpGet]
    [ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json)]
    public static void GetTableResultsUsingEditorNet()
    {
       HERE THE CODE TO GET WHICH RETURN DATA. ITS THE SAME AS THE ONE IN THE[ Webforms/ ASPX example.](https://editor.datatables.net/manual/net/webform " Webforms/ ASPX example.")
    }
    

    For the create process i did the following

    [WebMethod]
    [HttpPost]
    [ScriptMethod(ResponseFormat = ResponseFormat.Json)]
    public static void CreateVacationCalendar()
    {
      HERE THE CODE WHICH IS THE SAME AS THE GetTableResultsUsingEditorNet()
    }
    

    This last is not even flagged in visual studio debug like the Get. The ajax response is empty.
    After this call the get call is done but return a 404 error with this response url :
    http://localhost:48849/MyProject/CreateVacationCalendar/GetTableResultsUsingEditorNet?_=1568222333345.

    That is why i think the Editor is not working with WebForms because is looks like this last url is an mvs logic where the Controller is specified along with the the method name and parameters.

  • allanallan Posts: 63,439Questions: 1Answers: 10,459 Site admin

    If you "View source" on the generated HTML page, can you show me the Javascript that is created by ASP please? I'm wondering if you just need: url: '/<%...' to make it an absolute path rather than a relative one.

    Allan

  • allanallan Posts: 63,439Questions: 1Answers: 10,459 Site admin

    Forgot to say that I've marked your account to bypass the spam filter. Not sure why it was being picked before.

    Allan

  • dashyferdashyfer Posts: 7Questions: 1Answers: 0

    Hello Allan
    Everything happening here is after i clicked CREATE button

    Here is what i have when i use AbsolutePath
    Editor block:

    Datable block:

    XHR console:

    When i have a string path like "Team_VacationCalendar.aspx/CreateVacationCalendar"
    The Editor and Datatable block display the same in the view source but the XHR Console is different:

    But i still got an error that point me to https://datatables.net/manual/tech-notes/12

    I tried the resolution suggested here and got a TypeError: i is undefined. When i look for this error it always refer to an html problem but i am not sure i have one.
    Here is my table just in case:

  • allanallan Posts: 63,439Questions: 1Answers: 10,459 Site admin

    I don't actually see the Team_VacationCalendar.aspx/CreateVacationCalendar request in your screenshots. They both show for Get....

    Are you able to give me a link to your page so I can take a look please?

    Thanks,
    Allan

  • dashyferdashyfer Posts: 7Questions: 1Answers: 0

    Unfortunately i cannot give you a link because the dev is not publish yet and i need to make it work before plus we would really like to buy it for our solution

    The Team_VacationCalendar.aspx/CreateVacationCalendar is the first request on XHR screenshot. The response sent is an internal error as well.

    Please if you have any idea about the issue just point me where to look. Are there other people working with Editor on a WebForm project?

  • allanallan Posts: 63,439Questions: 1Answers: 10,459 Site admin

    Ah - sorry. I was looking at the bottom where the highlighted row is.

    The documentation we have for WebForms is available here.

    There is something about the relative URLs that is causing the issue here. Do you know the absolute URL that the requests should go to? And what's the URL that your page is loading (i.e. shown in your browser's location bar). From that we can see the mapping between them.

    Sorry I'm not able to give a simple answer - its difficult to know exactly what is going wrong without being able to see it.

    Allan

This discussion has been closed.