1

Using VS'12 KendoUI - C# asp.net MVC EF Code First Internet Application Template

  • I have finally gotten my Kendo DDL ( DropDownList ) to work,

    I was working on the post ActionResult when I found that

    if (ModelState.IsValid) is Always false when I click on My kendoUI Upload button ( the one bound in the control)

enter image description here

  • If however i click on the Regular submitt button <input type="submit" value="Upload" id="do" class="k-button"/> the ModelState.IsValid is true, but none of my "Upload selected files" were in the [Httppost] actionResult

My Question is simple , how do i Post both of them to my Controller at once?

here is a little example of my code ( the 2 buttons )

<div>    
     <p>
        <input type="submit" value="Upload" id="do" class="k-button"/>
    </p>
</div>

@(Html.Kendo().Upload()
        .Name("attachments")
        .Async(async => async
            .Save("Index", "ImageUpload")
            .AutoUpload(false)
        )
)
4

1 回答 1

2

您将上传控件配置为异步上传文件;因此,它不会表单一起发布。如果您希望表单数据和文件同时POST 到同一个控制器,那么您需要将上传控件配置为同步,而不是异步,并且您需要添加enctype="multipart/form-data"<form/>标签。然后在您的 MVC 控制器中,确保您的参数IEnumerable<HttpPostedFileBase> attachments之一与您的表单数据模型参数一起。

于 2013-08-30T05:48:32.657 回答