6

In Page_Load() function, I have populated an arraylist and a hashtable. I need to read their values in the $(document).ready(function(){...}.

I am a beginner in terms of ASP.NET and jQuery. Please suggest a way to do it.

cheers

4 Answers 4

5

you can use PageMethods to make a call to your aspx page from JS. Here is a nice article on how to use page method with jQuery. You can return your "whatever" in your page method. If you want to serialize your server side objects before passing them to the client side, you can serialize them to JSON . Here is an example. You would just read your json data after your ajax call is successful("success: function(msg){//do something}") and update your HTML accordingly

Sign up to request clarification or add additional context in comments.

Comments

0

you can use Page.ClientScript property to register arrays, scripts etc.

For more information view MSDN

Comments

0

you can create a page.method in server side and call it in the client side script that return an array of values

by adding 

<scriptManager EnablePageMethods="true">

in the server side you create a function that return an array of values
ex:  GetArrayResult()


  if you intersting in this i will give you the rest of example

1 Comment

@peacmaker:you dont need EnablePageMethods="true" to call a page method if you are using jQuery. see encosia.com/2008/05/29/…
0

JSON.Net will help you serialize the hashtable and array to JSON, and you can store these in a hidden field. Then on the client side you can deserialize the strings to your javascript variables with:

var array = JSON.parse($('#hiddenTextField').val());

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.