2012-06-22 41 views
0

我有一個問題,我有價值如下,我在行動方法中設置和隱藏的值在視圖中可用。現在,當我將表單發佈到一個操作方法時,隱藏的字段值就消失了。對此有何想法?MVC3隱藏的價值不堅持之間的形式回發

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

您是如何獲得價值的?發佈(雙關意圖)您的控制器正在接收該值的操作... –

+0

已更新代碼,我有一個按鈕,其中點擊操作方法 – user1475788

回答

1

嘗試用

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

確認在螢火蟲或提琴手該值發佈到請求中的服務器替換

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

+0

找到的解決方案。我的頁面有點棘手。在我保存之前,我必須在控制器操作方法中執行此操作。 ModelState.Remove( 「LoadListStoredFileName」);.這照顧了它,現在我可以輕鬆評估正確的價值 – user1475788