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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:37:32+00:00 2026-05-27T18:37:32+00:00

I created a new object() in Javascript, put some values into it and passed

  • 0

I created a new object() in Javascript, put some values into it and passed it to a PageMethod…

var filters = new object();

filters.Name = $("#tbxName").val();
filters.Age = parseInt($("#tbxAge").val());

PageMethods.getPeople(filters, getPeopleCallback);

… which, in it’s signature, receives an dynamic argument.

[WebMethod]
public static object getPeople(dynamic filters)
{
    ...

The whole code compiles and run with no problems, except for the server side PageMethod, which understands the dynamic parameter as a Dictionary.

When I debug the code to see the definition of the filters object, it shows me the following type: filters = {System.Collections.Generic.Dictionary<string,object>}

So, the only way deal with it is using it as a Dictionary…

var name = filters["Name"];
var age = filters["Age"] as int?;

.. But my intention was to use it as a Dynamic object

var name = filters.Name;
var age = filters.Age;

I know that this is not a big deal at all, and there is absolutely no problem for me to access it as a Dictionary (and I also know I can make a DynamicObject “Proxy” to access the Dictionary like a dynamic object).

I just want to understand this. So:

  1. Why the PageMethod understands it as a Dictionary?
  2. Is there a way to make this work as a Dynamic object (except for the “Proxy” approach)?

I was hoping that this could work because I usually define those Filter Classes on Server Side and create it in Javascript following the same structure, and the PageMethod understands it and convert it correctly when I define that Type as a argument (eg: getPeople(Filters filters)). So, I was wondering if it could do that also with dynamic objects (saving me time and unnecessary classes).

I appreciate your time and help.

  • 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-27T18:37:32+00:00Added an answer on May 27, 2026 at 6:37 pm
    1. The reason that the page method treats that as a Dictionary is because of how JavaScriptSerializer works internally. Since all JSON objects can be represented as a Dictionary<string, object>, JSS’ first pass is to convert the JSON string into a Dictionary (if no custom converters for the target type are registered) and you end up with that Dictionary as the end result of the conversion for dynamics.

    2. Not easily.

    You could experiment with writing your own JavaScriptConverter for dynamic. This is an example of something in the same ballpark that I wrote a while back: https://gist.github.com/6cfcdfdf2a117fa5e81b

    Mine’s customizing the serialization behavior instead of deserialization, but you can implement your own code in the Deserialize method to do that.

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

Sidebar

Related Questions

the following code (from a database object created for each new view): -(void)update:(NSString *)queryText{
Does a new SessionFactor y and Session object have to be created for each
i have a javascript module name SceneModule, see the code snippet below var SceneModule
I'm trying to build modal windows on the fly from single javascript object passed
I have a collection of objects in JavaScript like this: Object collection = new
As it is now I create a JavaScript object and then stringify it, put
I have created new rows using Javascript function addRow(id) , but I can't delete
First i have declare that i am new to javascript. I have created a
window.global_array = new Array(); window.example = function() { var x = new Object(); x['test_property']
I am tryıng to create new object of other class ın a for loop.

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.