Transmitting Arrays between View and Controller in the MVC Framework

I am currently attempting to transfer the values from the view to the controller

        var ParamAliasArray = new Object();

        for (var i = 1; i <= 1; i++) {

            ParamAliasArray[i] = $("#txtParamAlias" + i).val();
        }
        var ParamValueArray = new Object();

        for (var i = 1; i <= 4; i++)
        {
            ParamValueArray[i] = new Array();
            for (var j = 1; j <= 1; j++) {

                ParamValueArray[i][j] = $("#txtParamValue" + i).val();
            }
        }

One array is 1D and the other is a 2D array that I am sending as follows:

        jQuery.ajaxSettings.traditional = true

        $.ajax({
            type: 'Post',
            dataType: 'json',
            url: 'Register/GetRegDataFromuser',
            data: JSON.stringify({ GloabalAppID: GlobalAppID,
                    TransactionID: TransactionID,
                    OwnerID: OwnerID,
                    ParamAliasArray: ParamAliasArray,
                   ParamValueArray: ParamValueArray }),
            contentType: 'application/json; charset=utf-8',
            async: false,
            success: function (data) {
                console.debug(data);
            },
            error: function (data) {
                console.debug(data);
            }
        });

The action method in my code looks like this:

public ActionResult GetRegDataFromuser(int GloabalAppID, int TransactionID, string OwnerID, string[] ParamAliasArray, string[][] ParamValueArray)
{

---some logic--

}

At present, I am facing issues passing the array to the action method from the View. Any assistance would be greatly appreciated.

Thank you in advance.

Answer №1

Make sure to include the following line of code:

ParamValueArray[i][j]=new Array();

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Set $scope.model childs to an empty string or a null value

While working on a form, I am using a $http request to send the information through Angular in the following manner: $http({ method:"POST", url: "controllers/servicerequest.php", data: { servicerequest: $scope. ...

Having trouble displaying the Chrome context menu for a specific Chrome extension

I've read through several posts on this topic, but I'm still struggling to identify the issue with my implementation of the Chrome contextMenu API. I simply copied the code from a tutorial on Chrome APIs, and though there are no errors, the menu ...

SolidJS seems to be behaving strangely by rendering content twice when incorporating routing

Just diving into SolidJS and came across an issue where my app seems to be rendering twice. I have a hunch that this has to do with how I'm handling routing. To demonstrate the problem, I've put together a simple example: app.tsx import { Suspen ...

What is the correct location to define the "env" setting in the eslint.config.js file?

In 2022, ESLint rolled out a new configuration system called the "flat config" here. Check out the documentation for the new "flat config". | Old configuration system documentation here. The "flat config" documentation shows that the `eslint.config.js` ...

Check to see if two sets of coordinates fall within the specified radius

I'm currently working on analyzing the collision data for major intersections in my city by aggregating it with the location information. My main goal is to determine the number of accidents that occurred within a 20-meter radius of each intersection. ...

ASP.NET page experiences issues with executing Javascript or jQuery code

Having trouble with client scripts not functioning correctly on a child page that utilizes a master page. Looking for help to resolve this issue. <%@ Page Title="" Language="C#" MasterPageFile="~/Store.Master" AutoEventWireup="true" CodeBehind="NewSt ...

Guide to assigning an integer value to a string in Angular

Is there a way to change integer values in a table to actual names and display them on a webpage by setting a scope in the controller and passing that string to the HTML? For example, this is an example of the HTML code for the table row: <thead> ...

Transferring token values between collections in POSTMAN - AUTOMATION | NEWMAN: A step-by-step guide

My goal is to streamline my unit test cases by utilizing the POSTMAN Collections API & NEWMAN. I successfully created two test cases that are performing as expected. Upon exporting the collection from POSTMAN, I proceed to generate the test report using NE ...

Enhance Website User Experience: Keeping Track of Scroll Position When Users Navigate Back in Browser

Have you ever experienced the frustration of scrolling through a page with infinite scroll, only to click on a link and then go back to find that you've lost your place in the scroll? You're scrolling down a lot, You click on a link from the i ...

Generate a unique sequence not functioning

I'm attempting to generate a unique string composed of random characters, similar to the example found at this source. $(document).ready(function(){ $('#randomize').click(function() { var str = ""; var possibleChars = "michaeljo ...

Loop through an array of objects in Node.js using ng-repeat

I have integrated angularJS with a node back-end that transmits data using socketio. When I attempt to display the data using ng-repeat, I encounter an issue. If I set the initial data within the controller, ng-repeat functions properly. However, if I add ...

Scrolling causes a fade effect with the opacity value adjusting

Can someone help me with my script? jQuery(document).ready(function(){ jQuery(window).scroll(function () { var scrollTop = jQuery(window).scrollTop(); var height = jQuery(window).height(); jQuery('.background_top_dis ...

Using Slick Carousel alongside Browserify for a seamless integration with CDN jQuery

Despite browsing through all the responses on SO regarding this issue, I still haven't found a solution. In my project, I have jQuery loaded via Google CDN. Additionally, I am using babelify, browserify and browserify-shim in an attempt to make slick ...

Apply a unique color to the highest value within each column using AngularJS ng-repeat

I just started learning Angularjs, and I'm not sure how to achieve this. I want to highlight the member with the highest Score, Missed, and Field Goal percentage by adding color. Is there a way to do this? https://i.sstatic.net/9KF5D.png Is it poss ...

Tips for making an image box with a rollover effect

I need help figuring out how to create a unique user experience within a container that is 500px wide and 800px tall. The container currently has an image as a background, and I want to add a "sign up" button in the middle. When this button is clicked, I w ...

What is the correct way to accurately determine the width of a block being displayed with the flex-direction:column property?

For instance: HTML console.log($('.container').width()); // 600px as we defined in css. console.log($('.list').width()); // 600px console.log($('.box').eq('-1').position().left + $('.box').outerWidth( ...

Extract a free hour from the JavaScript time array without any filtering

In my Javascript array, I have the teaching schedule of a teacher for the day. { "time": [ { "start":"10:00","end":"11:00" }, { "start":"12:00","end":"01:00" }, { "start":"04:00","end":"06:00" } ] } My goal is to determine the free hours in the abo ...

Personalizing plot choices in highchart visuals

I am facing some styling issues with a highchart chart container in Angular that contains a marker, a line, and an area graph. I want to display labels on the graphs without using a tooltip option, but I am having trouble with label positioning. Click her ...

Error: The property 'length' cannot be read from an undefined parent causing Uncaught TypeError

Hey there, take a look at this cool stuff http://jsfiddle.net/J9Tza/ <form class="validation"> <div> <input type="email" class="form-control" id="inputEmail" name="email" placeholder="Email" pattern=".{3,200}" title="3 to 200 characters" r ...

In what way does Google+ make their logo come to life on the left side of the navigation bar when the scrollbar is minimized?

I'm curious about the animation Google+ uses to make their logo slide in on the navigation bar when it shrinks. I've managed to shrink the scrollbar on scroll, but I can't quite replicate their technique for animating the icons. I'm eag ...