Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8550783
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T14:02:15+00:00 2026-06-11T14:02:15+00:00

I have a text file and when users upload the file, the controller action

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T14:02:16+00:00Added an answer on June 11, 2026 at 2:02 pm

    $("#ExceptionString").val() is going to return a single string. This means your call to .load is just posting a single name/value pair to your MVC application.

    You need it to be posting a collection of name/value pairs. The name will be the same: the name of the collection with an indexer. The value will be the exception string. This is going to take some significant refactoring.

    Here’s basic way this could work:

    View code:

    <form action="@Url.Action("ListTestExceptions", "RunLogEntry")" TYPE="POST">
    @{ int counter = 0;}
    @foreach(var exception in Model.ExceptionString)
    {
    
      <input id='@("ExceptionString["+counter+"]")' type="hidden" value='@exception' />
      @{ counter =counter + 1; }
    }
    </form>
    

    JS code:

    $.ajax({
            url: runlogTestExceptionUrl,
            data: $(this).serialize(),
            success: function(data) {
                 $('#inputTestExceptions').html(data);
            }
    });
    

    Controller action is unchanged:

    [HttpPost]
        public ViewResult ListTestExceptions(List<string> ExceptionStrings)
        {
    

    Obviously this isn’t going to integrate instantly with your code. But this would be the way to post data from a form to a single collection variable in MVC.

    Note: I’m a little rusty on the razor syntax so there may be some little syntax issues. I’ll fix them as I find them.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form that allows users to upload text AND a file. However,
i have a java ee project which has a text file that uses a
I have text file with some stuff that i would like to put into
I have Text file that contains data separated with a comma , . How
I have a text file that I want to edit by rewriting it to
I have a text file and I would like to parse it using regular
I have a script that lets the user upload text files (PDF or doc)
I am making an application that allows users to upload a file in a
My Ruby on Rails application uses S3 and Paperclip. I have users upload a
On the site I am developing, I have a file input that users can

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.