access C# object from Javascript - need help converting to the correct object in JS

I have an object in c# which is

_temperatureData = new float[320, 240];

Open in new window


it looks like this:
cobj
I'm calling this in c#
 System.Web.Script.Serialization.JavaScriptSerializer jSearializer = new System.Web.Script.Serialization.JavaScriptSerializer();
            ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "genericName", "SendCSharpTempDataToJS(\'" + jSearializer.Serialize(_temperatureData) +"\');", true);

Open in new window


and then in my aspx page, i can successfully do this:
 function SendCSharpTempDataToJS(_temperatureData) {
            var mystring = "";
            console.log(_temperatureData);
        }

Open in new window


I now need to convert the object to the same type I had in the code behind, as i need to access x y data like [0,1] and retrieve the value 280

Any ideas how I would do that?
websssAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Julian HansenCommented:
Your serializer is creating JSON - which will then be passed to the function as a string  - and then use it like this
 function SendCSharpTempDataToJS(_temperatureData) {
            var mystring = "";
            var data = JSON.parse(_temperatureData);
            console.log(data.x);
        }

Open in new window

0
websssAuthor Commented:
thanks, that comes in as "undefined"
0
Julian HansenCommented:
I don't know what your structure looks like. In your post you said
as i need to access x y data like [0,1] and retrieve the value 280
The console.log(data.x) was merely a sample - I was expecting you to adjust for your specific data.
If you do this
function SendCSharpTempDataToJS(_temperatureData) {
  var mystring = "";
  var data = JSON.parse(_temperatureData);
  console.log(data);
}

Open in new window

You will see what the data structure looks like. If you are still having trouble identifying the value you want to access then post the JSON from your function definition so we can have a look at it
1. View Source
2. Find the function SendCSharpTempDataToJS
3. Copy the function as it is in the source and paste it here.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Julian HansenCommented:
It appears your data is an array of values do you want to access a specific value or all values in the array?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.