multiple partial views with same kendo mvc upload control

1.7k views Asked by At

I had a partial view which is having a Kendo MVC upload control. And now i need to use this partial view multiple times in a single .cshtml page.

Am facing problem with Control's ID and DOM conflicts... Like first Kendo upload is coming properly but second kendo upload is failing to load in UI.

So I came up with a dynamic .Name (...) so that whenever a kendo upload gets loaded it will be having unique ID.

Now the problem came with controller method. Here I need to get IEnumerable(HttpPostedFileBase) object on button click.

Am bit lost. Any hint is very helpful.

Rgds,

pavan

Edit To be more clear Let's say we had a partial view with textbox and button. on clicking the button we need to validate the textbox. But if the same partial view need to be used multiple times under same CSHTML is the one am facing now.

2

There are 2 answers

0
Mahdi Ahmadi On

I had the same problem too,but my problem was in MultiSelectFor() and I resolved it modifying the id of the kendo element. Look the next code:

Html.Kendo().MultiSelectFor(a => a.FeederIds).AutoClose(false)
                .HtmlAttributes(new { id = "VisitProgramFeederIds" })
2
Juan Carlos Velez On

I had the same problem, and I resolved it modifying the name of the kendo upload with the HtmlAttributes method (.HtmlAttributes(new {name="files" })). Look the next code:

@(Html.Kendo().Upload()
                .Name("files_" + Model.ID)
                .HtmlAttributes(new {name="files" })
                .ShowFileList(true)
                .Messages(m => m.Select("Asociar documentos").StatusUploading("Cargando...").StatusUploaded("Cargado!").Retry("Reintentar").HeaderStatusUploading("Cargando...").HeaderStatusUploaded("Listo!"))
                .Multiple(true).Async(async => async.AutoUpload(true).Save("Upload", "PQRSF", new { id = Model.ID }))
                .Events(events => events
                                    .Complete("uploadFile_OnComplete")
                                    .Error("upload_OnError")
                                    .Upload("upload_OnUpload")
                        )
            )