2012-04-26 3 views

ответ

3

Вот решение, которое мы разработали для динамического изменения saveUrl в виджетах загрузки Kendo UI. Код

Контроллер:

public class MediaController : ApiControllerBase 
{ 
    public Task<HttpResponseMessage> Post() 
    { 
     var queryVals = Request.RequestUri.ParseQueryString(); 
     string idValue = queryVals["id"].ToString(); 

     ... CODE REMOVE FOR BREVITY 
    } 
} 

И код сценария:

<div style="width:45%"> 
      <input class="upload" name="files" id="files" type="file" upload-id="02ebeebf-98aa-459b-b41f-49028fa37e9c" /> 
      <input class="upload" name="files2" id="file1" type="file" upload-id="499499D3-1C80-4930-8C8D-C87F17884D3F" /> 
     </div> 

     <script> 
      $(document).ready(function() { 
       $(".upload").kendoUpload({ 
        async: { 
         saveUrl: "/API/Media", 
         autoUpload: true 
        }, 
        upload: function onUpload(e) { 
         var uploadId = e.sender.wrapper.prevObject.attr("upload-id"); 
         e.sender.options.async.saveUrl = "/api/media?id=" + uploadId; 
        }, 
       }); 
      }); 


     </script> 
+0

эта строка кода спасла мой день: e.sender.options.async.saveUrl = «/ API/идентификатор носителя = "+ uploadId; Спасибо. –

Смежные вопросы