0

我有一个问题,我在操作方法中设置的值如下,并且隐藏的值在视图中可用。现在,当我将表单发布到操作方法时,隐藏字段值消失了。对此有什么想法吗?

   @using (Html.BeginForm("Create", "RunLogEntry", FormMethod.Post, new { enctype = "multipart/form-data" }))
        {

        @Html.HiddenFor(model => Model.OutputStoredFileName)

        <button name="submit" class="art-button" type="submit" value="Populate" style="width: 100px">
                Attach</button>
    }


 [HttpPost]
public ActionResult Create(RunLogEntry runLogEntry, String ServiceRequest, string Hour, string Minute, string AMPM,string submit, IEnumerable<HttpPostedFileBase> file, String AssayPerformanceIssues1)
        {
        if(submit == "Populate")
         {
               //Runlogentry is the model
               if ((System.IO.File.Exists(runLogEntry.OutputStoredFileName)))
                            System.IO.File.Delete(runLogEntry.LoadListStoredFileName);  
4

1 回答 1

1

尝试更换

@Html.HiddenFor(model => Model.OutputStoredFileName)

@Html.HiddenFor(model => model.OutputStoredFileName)

在 FireBug 或 Fiddler 中确认该值已在请求中发布到服务器。

于 2012-06-22T22:01:45.860 回答