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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T02:04:18+00:00 2026-06-04T02:04:18+00:00

My application is asp.net. I have to send some values back to server. For

  • 0

My application is asp.net. I have to send some values back to server. For this I create a object serialize it and send it to server. At server I try to de-serialize it
Following is my code

   [Serializable]
    public class PassData
    {
        public PassData()
        {  
        }

        public List<testWh> SelectedId { get; set; }

        public string SelectedControlClientId { get; set; }

        public string GroupTypeId { get; set; }

        public string SectionTypeId { get; set; }

  }


    [Serializable]
    public class testWh
    {
        public testWh()

        {
        }
        public string Id { get; set; }
    }


JavaScriptSerializer serializer = new JavaScriptSerializer();
//this can not serialize the SelectedId and the count remains 0
PassData data = serializer.Deserialize<PassData>(jsonString);
//this serialize in an anonymous object with key value pair
var data2 = serializer.DeserializeObject(textHiddenArguments.Text);

Following is my Json Serialized String

{
   "SelectedId":{"0":"ABCD","1":"JKLM"},
   "SelectedControlClientId":"YTUTOOO",
   "GroupTypeId":3,
   "SectionTypeId":"1"
}

quotes escaped string

"{\"SelectedId\":{\"0\":\"ABCD\",\"1\":\"JKLM\"},\"SelectedControlClientId\":\"YTUTOOO\",\"GroupTypeId\":3,\"SectionTypeId\":\"1\"}"

My Problem is Selected Id is array of testWH object. But when I try to desrialize it, the SelectedId property of PassData which is list does not get serialized and count remains zero.

I tried using array instead of List, which gave an exception “no parameter less constructor…”

Could any one explain the what I am doing wrong here ?

  • 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-04T02:04:19+00:00Added an answer on June 4, 2026 at 2:04 am

    The key problem here is that the JSON doesn’t match the objects you have constructed. You can see this by writing the data you want and serializing:

    var obj = new PassData
    {
        SelectedId = new List<testWh>
        {
            new testWh { Id = "ABCD"},
            new testWh { Id = "JKLM"}
        },
        GroupTypeId = "3",
        SectionTypeId = "1",
        SelectedControlClientId = "YTUTOOO"
    };
    string jsonString = serializer.Serialize(obj);
    

    which gives JSON like:

    {"SelectedId":[{"Id":"ABCD"},{"Id":"JKLM"}],
     "SelectedControlClientId":"YTUTOOO","GroupTypeId":"3","SectionTypeId":"1"}
    

    So now you need to decide which you want to change; the JSON or the classes. The following alternative class works fine with your original JSON, for example:

    public class PassData
    {
        public Dictionary<string,string> SelectedId { get; set; }
        public string SelectedControlClientId { get; set; }
        public string GroupTypeId { get; set; }
        public string SectionTypeId { get; set; }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

im trying to create a database for a feedback application in ASP.net i have
We have a Web application (ASP.NET) which displays in some page links to miscellaneous
I have a web application on ASP.NET (C#) that has some precompiled components. I've
I have a client/server application (asp.net), which has a textarea which a user types
I have an old ASP.NET application. We send out httpWebRequest to a remote REST
I have created an ASP.net application with several aspx. Some of them are used
I have a Generic HTTP Handler (*.ashx) in my ASP.Net application which performs some
I have coded some JavaScript to perform an ajax call in an asp.net application.
I have an ASP.NET web application and I'm thinking about the following: before sending
I have an application (ASP.NET MVC) that uses a Next New method to get

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.