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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T10:13:04+00:00 2026-05-25T10:13:04+00:00

I have spent WAY too much time trying to figure out how to pull

  • 0

I have spent WAY too much time trying to figure out how to pull all the values I need to from my C# application using JS and JSON. It works fine when I just use simple structures, such as an array, but I need to be able to grow the list at runtime.

Right now, the best I could figure out was doing a Dictionary with an incrementing key value, and the other 3 values as a class object. However, this seems to crash out my C# application.

What would be the best way to do this?

Relevant C# Code:

public class ChatData
{
    string userName;
    string message;
    System.DateTime timestamp;

    public ChatData(string name, string msg)
    {
        userName = name;
        message = msg;
        timestamp = System.DateTime.Now;
    }
}

        else if (string.Equals(request, "getchat"))
        {
            //string since = Request.Query.since;

            Dictionary<int, ChatData> data = new Dictionary<int, ChatData>();

            data.Add(1, new ChatData("bob", "hey guys"));
            data.Add(2, new ChatData("david", "hey you"));
            data.Add(3, new ChatData("jill", "wait what"));

            return Response.AsJson(data);
        }

Relevant Javascript:

function getChatData()
{
    $.getJSON(dataSource + "?req=getchat", "", function (data)
    {
        //$.each(data, function(key, val)
        //{
            //addChatEntry(key, val);
        //})
    });
}
  • 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-05-25T10:13:04+00:00Added an answer on May 25, 2026 at 10:13 am

    Why not simply use a typed list? Also, you’ll need a default constructor to serialize/deserialize it. Note how I’ve modified your class to use properties
    as well. Note, as @rudolf_franek mentions, you can add an ID property to the ChatData class if you need to be able to link to it.

    public class ChatData
    {
         public ChatData()
         {
             TimeStamp = DateTime.Now;
         }
         public int ID { get; set; }
         public string Who { get; set; }
         public string Said { get; set; }
         public DateTime TimeStamp { get; set; }
    }
    
    ...
    
    var data = new List<ChatData>
    {
        new ChatData { ID = 1, Who = "bob", Said = "hey guys" },
        ...
    };
    
    return Response.AsJson( data );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have spent way too much time trying to sort this little issue out.
I have spent way too much time trying to solve what seems to be
This is probably simple, but I have spent way too much time trying to
I have spent way too much time looking for the files owner icon to
I am having an issue that I have spend way too much time trying
I have spent way too much time (over an hour) on what I though
I have spent all Friday and Saturday on this and I am running out
I have spent at least 2 weeks now trying to find out how to
I have spent the afternoon trying to wrap my mind around how to translate
I have spent some time now to solve a problem for which i have

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.