0
votes

There is a default submit button for the @FileUpload.GetHtml. But I am expecting to have a submit button inside the Html begin form and use that substitution to submit the list of files with some more parameters. But when I do that the passing IEnumerable is always null in the Action method.

This is my Action method: [HttpPost] public ActionResult Change(IEnumerable filesList, Guid ID, string Btn) {....

    @using (Html.BeginForm("Change", "Home",FormMethod.Post))
    {
      <textarea id="textArea" name="epost2" class="frm_txtfield_big" style="float:left; width:638px; height:200px;"></textarea>

      <input type="hidden" name="supportID" value="@Model.ID" />

      @FileUpload.GetHtml(name: "ChooseFile",initialNumberOfFiles: 1,allowMoreFilesToBeAdded: true,includeFormTag: false)

      .......}

But this is not passing the list of files to the method.

Am doing it wrong or what is the wrong with the code.

1
FileUpload is server control of asp.net webforms. It is not about asp.net mvc. Are you sure that you use right tag?Kirill Bestemyanov
Well I have seen of these in some tutorials as well. And the view is giving exactly what I was expecting. But its not submitting.diyoda_

1 Answers

1
votes

I have not included the enctype = "multipart/form-data" inside the Html.BeginForm So that the value is not taken to the file input. Now it ok. This will give you a good explanation.