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 7811105
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T04:02:35+00:00 2026-06-02T04:02:35+00:00

I have the following JavaScript code that gets the Id property (Guid) from every

  • 0

I have the following JavaScript code that gets the Id property (Guid) from every user row in a Kendo UI grid. Now I am wondering how best to compose these Id’s and the owner roleId into a JSON object that I can pass to an MVC3 action method. Versus my silly string concat.

$("#command-add-selected").click(function () {
    var json = "roleId: '51FC554E-353C-4D55-BE52-1B4BF9D2F17F', users: [";
    var avail = $("#availableUsersGrid").data().kendoGrid._data;
    for (var i = 0; i < avail.length; i++) {
        json += "{ Id: '" + avail[i].Id + "'},";
    }
    json = json.slice(0, -1);
    json += "]";
    alert(json);
    return false;
});

The action method can be GET or POST and need not return any value (this is another puzzle here, no returned view). All it does is domain updates that are fetched by other ajax code subsequent to the above code.

How can I pass the above type JSON to an action method essentially of void return type?

EDIT: This question answered the minor part of my question nicely, with how to dynamically add items to an array with push.

  • 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-02T04:02:36+00:00Added an answer on June 2, 2026 at 4:02 am

    1.first of all u dont need to create the full json ur self use JSON.Stringify() method to change the javascript object to JSON string.
    2.after u have created the JSON string u can GET or POST it to any normal method in any MVC Controller of visibility public.
    even if the signature of the action method is like public ActionResult MehodName(string jsonString) u can always return null.
    3. u can use built in JavaScriptSerializer class in System.Web.Script.Serialization namespace to deserialize the json string u recieve in the action to create an object with the same propertiese
    Edit:-
    make a javascript array names users then inside the for loop use .push() function of javascript to insert the objects like this

    var users = [];
    for(something)
    {
    var user = {"Id":"YOUR ID VALUE"};
    users.push(user)
    }
    var objectToSerialize = {"roleId":"YOUR ROLE GUID","Users":users};
    var jsonString = JSON.stringify(objectToSerialize);
    

    Edit 2:-
    so going by your previous comments u dont want that u need to deseralize the whole JSON object. going by your object architecture even if ur action method has a signature like this

    public ActionResult GetUsersByRole(Users users)
    {
    //some code 
    }
    

    and Users class like this one

    class Users
    {
    public string RoleId{get; set;}
    public User[]{get; set;}
    }
    

    and User class like this

    class User
    {
    string Id{get; set;}
    }
    

    it would automatically bind property with your complex users object

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

Sidebar

Related Questions

I have some JavaScript code that works in IE containing the following: myElement.innerText =
I have the following (from Tridion PowerTools ), which gets a user name from
I have the following Javascript and Html code that works fine in an MVC4
I have the following JavaScript code which gets all of the id's of the
I have the following code that shows 5 posts each being the latest from
I have the following JavaScript code to pop up a window in Internet Explorer.
I have the following javascript code, which loads without error, however the update function
I have the following JavaScript code: Link In which the function makewindows does not
I have the following JavaScript code: oCoord = {x: null, y: null}; var aStack
I have the following Javascript code. When the page is loaded it is scrolled

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.