Reputation: 123
I have a question, I have value as below which I set in an action method and the hidden value is available in the view. Now when I post a form to an action method, the hidden field value is gone. Any ideas on this?
@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);
Upvotes: 0
Views: 2247
Reputation: 46008
Try replacing
@Html.HiddenFor(model => Model.OutputStoredFileName)
with
@Html.HiddenFor(model => model.OutputStoredFileName)
Confirm in FireBug or Fiddler that the value is posted to the server in the request.
Upvotes: 1