Editor data in Create Controller

Editor data in Create Controller

dpanscikdpanscik Posts: 202Questions: 47Answers: 0

The editor plugin is very confusing to learn how to use. Therefore I decided to dumb this down to a basic simple task. Using the editor to create a record using MVC scaffolding posted via AJAX.

In the Create controller I expect to see data coming in looking like this;

Instead I am getting data coming into the controller looking like this;

How can I pickup this data?

Typically I would pickup this data like this (below);

string GR_AirBillNumber = formCollection["GR_AirBillNumber"];

But attempting to pickup the data like this (below) does not work;

string Shop = formCollection["data[0][Day]"];

Answers

  • dpanscikdpanscik Posts: 202Questions: 47Answers: 0

    well you are so smart you answered your own question.

    string test0 = collection[0].ToString();
    string test1 = collection[1].ToString();
    string test2 = collection[2].ToString();

    etc...

  • allanallan Posts: 63,497Questions: 1Answers: 10,470 Site admin

    Hi,

    The way Editor submits data is described here. It uses HTTP parameters with names that are typically parsed by the server-side. This is not the case in .NET unfortunately. However, there are a few options:

    1. If you use our Editor server-side libraries, they handle all of this, including the insert, update and delete for you.
    2. Include the Editor libraries, but only use the DtRequest class which can transform the input into a .NET object.
    3. Use ajax.data to send JSON to the server rather than HTTP parameters. Then you can deserialise it using JSON.NET or similar.

    Allan

  • dpanscikdpanscik Posts: 202Questions: 47Answers: 0

    Hi Alan,

    Thanks for jumping in here.

    Unfortunately using the dll isn't a easy option for me (described in more detail in an adjacent post).

    Do you by chance have code samples to help pave the way for using option #2 and option #3?

  • allanallan Posts: 63,497Questions: 1Answers: 10,470 Site admin
Sign In or Register to comment.