MvcFileUploader icon indicating copy to clipboard operation
MvcFileUploader copied to clipboard

Problem using with PartialView

Open SwartHack opened this issue 8 years ago • 0 comments

Is there a sample for use with a partial view? I can't seem to get it to work round trip. Maybe I am just MVC dense but the upload view never gets the the controller response?! The file IS uploaded however!!! I have tried a number of different approaches: Action, RenderAction, RenderPartial, [ChildActionOnly]...and the result is always the same, the JSON response is just displayed in the browser (see attached), and the view never updates with status. I can recreate the issue using the MvcTestUpload view and controller. If I alter demo.cshtml to be a partial and modify the controller accordingly, it results in the same behavior.

Demo.cshtml

@using MvcFileUploader.HtmlHelper
@using MvcFileUploader.Models
<div class="well">
    <legend>Upload Inline</legend>
    <p class="help-block">jpg/png size max 5 MB</p>
    @(
        Html.MvcFileUpload()
        .UploadAt(Url.Action("UploadFile"))
        .UIStyle(UploadUI.Bootstrap)
        .WithFileTypes(@"/(\.|\/)(jpe?g|png)$/i")
        .WithMaxFileSize(5000000)
        .AddFormField("entityId", "1234")
        .RenderInline("_MvcFileupload")
    )

</div>
public class MvcUploaderTestController : Controller
    {
        public ActionResult Demo()
        {
            return PartialView();
        }

        public ActionResult UploadFile(int? entityId) // optionally receive values specified with Html helper
        {            
            // here we can send in some extra info to be included with the delete url 
            var statuses = new List<ViewDataUploadFileResult>();
            .....

I have looked around and have not found a solution specific to this package. I could try to hack around the package scripts, but prefer to use this package "as-is". If you have any pointers or suggestions, they are greatly appreciated. Thanks, Eric

screen2 screen3

SwartHack avatar May 25 '17 20:05 SwartHack