0

HTMLフォームで正常に機能するファイル入力を備えたフォームがあります。フォームを送信すると、ファイル入力で自分の値を取得できます。ただし、AJAXを使用する場合、ファイル入力フィールドは常にnullです。

この作品

@using (Html.BeginForm("ProcessSubmit", "Upload",
                     FormMethod.Post, new { id = "uploadForm", enctype =   "multipart/form-data" })) { 
    @(Html.Telerik().Upload().Name("attachments"))
    <p class="note">
    Maximum combined file size: 10 MB
   </p>
   <div style="margin: 20px 0 0 0;">
       <input type="submit" value="Send" class="t-button" />
       <input type="reset" value="Reset" class="t-button" />
   </div>
}    

and the controller: 
[HttpPost]
    public ActionResult ProcessSubmit(IEnumerable<HttpPostedFileBase> attachments)
    {
        if (attachments != null)
        {
            return Content("is not null");
        }
        return Content("null");
    }

しかし、これは機能しません

@using (Ajax.BeginForm("ProcessSubmit", "Upload",
                     new AjaxOptions { UpdateTargetId = "mydiv" })) { 
     <div id="mydiv"></div>
    @(Html.Telerik().Upload().Name("attachments"))
    <p class="note">
    Maximum combined file size: 10 MB
   </p>
   <div style="margin: 20px 0 0 0;">
       <input type="submit" value="Send" class="t-button" />
       <input type="reset" value="Reset" class="t-button" />
   </div>
}  

前者の場合、コントローラーは常に「is not null」を返しますが、後者の場合、コントローラーは常にnullを返します。:(

これはどうしたの?

4

0 に答える 0