HTML showing on trial

HTML showing on trial

tandrechttandrecht Posts: 3Questions: 1Answers: 0

Description of problem: I just downloaded and am trying the Editor trial. I used the WebForms demo at https://editor.datatables.net/manual/net/webform to build a simple test with my data. When I run it in my application, all I see is the html code, not the rendered table. This is going into a custom web control, so it has a larger ASP.NET page wrapped around it, but I don't know if that'll make a difference. If I have my content type as text/json, I only see the table html. if i set it as text/html, i get the json code, and then the rest of the page is rendered. How do I fix this so the table shows inside the control where I need it? My Page_Load is below, and almost identical to the example.

`
var request = HttpContext.Current.Request;

        using (var db = new Database("sqlserver", DatabaseReader.CONNECTION_STRING))
        {
            var response = new Editor(db, "TS_tblTimesheetDay", "TimesheetDayID")
                .Model<TimesheetDayModel>()
                .Process(request)
                .Where("TimesheetID", TimesheetId)
                .Data();

            Response.ContentType = "text/json";
            Response.Write(JsonConvert.SerializeObject(response));
        }`

Answers

  • tandrechttandrecht Posts: 3Questions: 1Answers: 0

    I just had a thought. This is setting the content to JSON, whereas the rest of my page is pre-built HTML. Is there a wrapper for this that puts the JSON into the HTML and still lets me do the editing? Or do I need to look at something else? Possibly changing to MVC if I can shoehorn it in?

  • allanallan Posts: 61,716Questions: 1Answers: 10,108 Site admin
    edited September 2020

    When using WebForms and Editor like this, you need two paths:

    1. The first to load the HTML for the page
    2. The second where the Ajax request is made to (to get the JSON data and to submit the edits).

    It sounds to me like you might be trying to do both through a single address?

    Allan

  • tandrechttandrecht Posts: 3Questions: 1Answers: 0

    I have no idea what you mean by trying to do this through a single address. The code I am writing is an ASP.NET custom control that will plug into a framework provided by our vendor, so I'm writing .ASCX files that will be inside an .ASPX page.

  • allanallan Posts: 61,716Questions: 1Answers: 10,108 Site admin

    What's the URL you are using to load the page? And what is the URL you are using for the ajax option in both DataTables and Editor?

    Allan

This discussion has been closed.