MVC3隐藏在表单回发之间不存在的值

时间:2012-06-22 21:51:03

标签: asp.net-mvc asp.net-mvc-3

我有一个问题,我在动作方法中设置的值如下所示,隐藏值在视图中可用。现在,当我将表单发布到动作方法时,隐藏的字段值消失了。关于这个的任何想法?

   @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);  

1 个答案:

答案 0 :(得分:1)

尝试替换

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

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

在FireBug或Fiddler中确认该值是否已过帐到请求中的服务器。