Click here to Skip to main content
15,867,686 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
The code below works. The controller receives the value "Test Value" when the Upload widget is executed.

However, I have a key value from the model that is displayed within this view that I need to send instead of the hardcoded text.

Note. This is a custom template within a grid popup editor.


ViewBag.Title = "Test Value";




JavaScript
@(Html.Kendo().Upload()
 .Name("files")
 .TemplateId("fileTemplate")
 .Async
     (a => a
         .Save("Save", "OpenRecords"), new { MyRequest = ViewBag.Title })
         .AutoUpload(true))
 )




C#
public ActionResult Save(IEnumerable<HttpPostedFileBase> files, string MyRequest)
{
    // The Name of the Upload component is "files"

    if (files != null)
    {
        foreach (var file in files)
        {
            // Some browsers send file names with full path.
            // We are only interested in the file name.

            var fileName = Path.GetFileName(file.FileName);
            var physicalPath = Path.Combine(Server.MapPath("~/App_Data"), fileName);
            // The files are not actually saved in this demo
             file.SaveAs(physicalPath);
             ViewBag.FileName = fileName;
             //return Content(physicalPath);

        }

    }

    // Return an empty string to signify success
    return Content("");


}
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900