I have a text file and when users upload the file, the controller action method parses that file using state machine and uses a generic list to store some values. I pass this back to the page in the form of a hidden field. Users can then click on a link which invoked a JS modal dialoag box and they could see the list and add comments for each item in the list. When they click on the link I am trying to post to an action method which would take that hidden field and do something with it and render a partial view. The problem is when i post to this action method, this field is being passed as null.
here is my code
@Html.HiddenFor(model => model.ExceptionString)
if (Model.ExceptionString != null)
{
if (Model.ExceptionString.Count > 0)
{
<div class="bodyContent">
<span class="leftContent">
@Html.Label("Test Exceptions")
</span><span class="rightContent"><span id="TestExceptionChildDialogLink" class="treeViewLink">Click
here to View Test Exceptions</span>
<br />
<span id="TestExceptionDisplay"></span>
@Html.HiddenFor(model => model.ExceptionString)
<input id="ExceptionString" type="hidden" value="@Model.ExceptionString" />
</span>
</div>
}
}
<div id="testExceptiontreeview" title="Dialog Title" style="font-size: 10px; font-weight: normal;
overflow: scroll; width: 800px; height: 450px;">
<div id="testExceptions">
</div>
<div id="inputTestExceptions" style="display: none;">
</div>
</div>
var runlogTestExceptionUrl = '@Url.Action("ListTestExceptions", "RunLogEntry")';
JS FILE
$("#inputTestExceptions").load(runlogTestExceptionUrl, { ExceptionStrings: $("#ExceptionString").val() });
Controller action
[HttpPost]
public ViewResult ListTestExceptions(List<string> ExceptionStrings)
{
Any ideas as to why exception string list is null while being passed by the JS to the abive action method?