SHARE
TWEET

Untitled

a guest Jun 19th, 2019 81 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. @model SIServices.ViewModels.SODViewModel
  2. @using (Html.BeginForm("Initiate", "SOD", FormMethod.Post, new { id =
  3.   "initiateSOD" })) // enctype = "multipart/form-data"
  4.  {
  5.       @Html.AntiForgeryToken()
  6.  
  7.       ...
  8.  
  9.       @* form inputs as html helpers *@
  10.       @* html table data is collected as json *@
  11.      
  12. var cols = [];
  13.    cols.push("DIGITAL_FILE_TYPE_ID");
  14.    cols.push("DOCUMENT_LAPI_ID");
  15.    var DigitalMaps = [];
  16.    $("table#digital-map-table tbody tr").each(function () {
  17.    data = {};
  18.  
  19.    var selectedDigitalMapVal = $(this).data("selectedDigitalMapVal");
  20.    data[cols[0]] = selectedDigitalMapVal;
  21.    var documentId = $(this).data("documentID");
  22.    data[cols[1]] = documentId.toString();                      
  23.    DigitalMaps.push(data);
  24.    data = {};
  25.  
  26.    });
  27.  
  28.     var headers = { __RequestVerificationToken:
  29.       $('input[name="__RequestVerificationToken"]').val() };
  30.  
  31.                 if (DigitalMaps != null) {
  32.                     $.ajax({
  33.                         headers: headers,
  34.                         url: "@Url.Action("Initiate")",
  35.                         type: "POST",
  36.                         cache: false,
  37.                         contentType: "application/json; charset=utf-8",
  38.                         data: DigitalMaps,
  39.                         dataType: "json",
  40.                         success: function (succ) {
  41.                             console.log(succ);
  42.                         },
  43.                         error: function (err) {
  44.                             console.log(err.statusText);
  45.                         }
  46.                     });
  47.                 }
  48.      
  49. namespace SIServices.ViewModels
  50.    {
  51.        public class SODViewModel
  52.        {
  53.           // a lot of properties - around 50
  54.           public int? DigitalMapId { get; set; }
  55.           public List<DIGITAL_MAPS> DigitalMaps { get; set; }
  56.      
  57. [HttpPost]
  58.     [ValidateHeaderAntiForgeryToken]
  59.     public ActionResult Initiate(SODViewModel vm)
  60.     {
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top