We are working on the Kendo MVC user interface, where we send data from one view to another, all data (test tag, drop-down list) is transferred to the next view, except for attachments (pdf, xlsx).
Below is the code that we wrote in the controller to capture from the view and save data and transfer the same data to another view and bind the data to the kendo controls (you can also control the download)
public ActionResult SaveData(System.Web.Mvc.FormCollection form, IEnumerable<HttpPostedFileBase> files) // insert operation { //*************************// if (form != null) { string ddluserexceptioncategory = Convert.ToString(form["txtexceptioncategory"], CultureInfo.InvariantCulture); if (!string.IsNullOrEmpty(ddluserexceptioncategory)) { ddluserexceptioncategory = ddluserexceptioncategory.Trim(); } if (ddluserexceptioncategory == "User Management") { //Bind the data to the class object(_clsObj) if (files != null) { TempData["FileName"] = files; _clsObj.Files = files; } TempData["SecondViewData"] = _clsObj; return RedirectToAction("ExceptionType", "Home", new { id = 0, regionId = _clsObj.RegionId, status1 = "New,In Progress", keyword1 = string.Empty }); } } string regions = "", statusValue = ""; if (form != null) { regions = form["hiddenregionselected"] + ""; statusValue = form["hiddenstatusselected"] + ""; } return RedirectToAction("homepage", "Home", new { region = regions, status = statusValue }); }
Below is the code that we associate with the request for the second
@if (TempData["FileName"] != null) { IEnumerable<HttpPostedFileBase> firstFile = (IEnumerable<HttpPostedFileBase>)TempData["FileName"]; <div class="k-dropzone"> <div class="k-button k-upload-button"> <input name="files" type="file" data-role="upload" multiple="multiple" autocomplete="off" tabindex="-1" class="valid" style="display: none;"> <input id="files" name="files" type="file" data-role="upload" multiple="multiple" autocomplete="off"> <ul id="files1" class="k-upload-files k-reset"> @foreach (var file in firstFile) { string filename= Path.GetFileName(file.FileName); <li class="k-file" data-uid="7aa03676-4dac-468e-b34a-99ac44d23040"> <span class="k-icon k-success">uploaded</span> <span class="k-filename" title="@filename">@filename</span> <strong class="k-upload-status"> <span class="k-icon k-delete"></span> </strong> </li> } </ul> </div> </div> <script> jQuery(function() {jQuery("#files").kendoUpload( {"select":uploadselect, "localization":{"select":"Browse file", "headerStatusUploading":"uploading..", "headerStatusUploaded":"uploded.."}, "async":{"saveUrl":"/Home/Save", "autoUpload":false,"removeUrl": "/Home/Remove"}});}); </script> } else { @(Html.Kendo().Upload().Name("files").Async(a => a.Save("Save", "Home").Remove("Remove", "Home").AutoUpload(false)).Multiple(true).Messages(m => { m.Select("Browse file"); }).Events(events => events.Select("uploadselect"))) }
Any suggestions or help are greatly appreciated.
asp.net-mvc kendo-ui
Dinesh haraveer
source share