Reputation: 3045
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)
<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)
)
)
Upvotes: 1
Views: 2763
Reputation: 4269
You configured your upload control to upload files asynchronously; therefore, it doesn't POST with the form. If you want both your form data and your files to POST at the same time to the same controller, then you need to configure your upload control to be synchronous, not Async, and you need to add enctype="multipart/form-data"
to the <form/>
tag. Then in your MVC controller, make sure one of your parameters is IEnumerable<HttpPostedFileBase> attachments
along with your form data model parameter(s).
Upvotes: 2