I have defined following hidden input fields in my form view,
Form:
@model Mysite.Models.FileUpload
@using Mysite.Models
@{
var FileUploadData = ViewData["FileUploadData"] as FileUpload;
}
@using (Html.BeginForm("LoadData",
"LoadAndAnalyzeData",
FormMethod.Post,
new { enctype = "multipart/form-data" }))
{
<div class="div-root" id="serverslist">
@Html.LabelFor(m => m.SelectedServer)
@Html.DropDownListFor(m =>m.SelectedServer, FileUploadData.ServersList)
</div>
<div class="div-root">
<label for="files">Choose File 1: </label>
<input type="file" name="file1" id="file1" />
</div>
<div class="div-root">
<input type="submit" id="upload" name ="FileUpload" value="Upload Files For Analysis" />
</div>
}
@using (Html.BeginForm("AnalyzeLoadedData", "LoadAndAnalyzeData"))
{
<input type="hidden" name="servername" id="servername" value='@ViewBag.servername' />
@ViewBag.servername
<input type="submit" id="analysis" name ="AnalyzeLoadedData" value="Analyze Loaded Data" />
}
I have a model where i have defined "servername" as below,
public string servername { get; set; }
When i click the submit the function AnalyzeLoadedData is not getting the servername as expected. But the page is displaying the server name as part of @ViewBag.servername on the page.
"servername The name 'servername' does not exist in the current context"
Please guide me what I'm missing here.