2017-05-15 6 views
0

HttpPostedFileBaseオブジェクトの一般的なリストでHtml.EditorForを使用する方法はありますか?Html.Editor一般的なHttpPostedFileBaseのリスト

ページの1つに誰かが最大3つのファイルを添付できるサイトを構築しています。私のコードは、現在、このようになります -

モデル -

public IEnumerable<HttpPostedFileBase> Attachments { get; set; } 

ビュー -

<div> 
    @{ 
     for (int i = 0; i < 3; i++) 
     { 
      <input type="file" name="Attachments[@i]" /> 
     } 
    } 
</div> 

EditorFor文で<input type="file" name="Attachments[@i]" />を交換するいくつかの方法がありますか?

+0

を使用することができ、この

<div> @{ for (int i = 0; i < 3; i++) { @Html.Editor("Attachments["+ i +"]", new { htmlAttributes = new { type = "file" }}) } } </div> 

または

<div> @Html.Editor("Attachments", new { htmlAttributes = new { type = "file" }}) @Html.Editor("Attachments", new { htmlAttributes = new { type = "file" }}) @Html.Editor("Attachments", new { htmlAttributes = new { type = "file" }}) </div> 

ようにそれを行うことができます –

答えて

0

あなたはまた `EditorTemplate`を作成TextBox

@Html.TextBox("Attachments",new { type = "file" }) 
関連する問題