如何在Html.BeginForm和sumbit FilesList中使用@ FileUpload.GetHtml [英] How to use @FileUpload.GetHtml inside Html.BeginForm and sumbit FilesList
问题描述
@ FileUpload.GetHtml有一个默认的提交按钮.但是我希望HTML开头表单中有一个提交按钮,并使用该替换来提交带有更多参数的文件列表.但是,当我这样做时,在Action方法中,传递的IEnumerable始终为null.
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.
这是我的操作方法: [HttpPost] 公共ActionResult更改(IEnumerable filesList,Guid ID,字符串Btn) {....
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.
推荐答案
我没有将enctype = "multipart/form-data"
包含在Html.BeginForm
内,因此该值不会被带到文件输入中.现在可以了.
这会给您一个很好的解释.
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.
这篇关于如何在Html.BeginForm和sumbit FilesList中使用@ FileUpload.GetHtml的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!